MCPcopy Create free account
hub / github.com/NVIDIA/DALI / SlicePythonOp

Class SlicePythonOp

dali/test/python/operator_1/test_slice.py:368–410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

366
367
368class SlicePythonOp(Pipeline):
369 def __init__(
370 self,
371 batch_size,
372 pos_size_iter,
373 num_threads=1,
374 device_id=0,
375 num_gpus=1,
376 axes=None,
377 axis_names=None,
378 normalized_anchor=True,
379 normalized_shape=True,
380 ):
381 super().__init__(
382 batch_size, num_threads, device_id, seed=12345, exec_async=False, exec_pipelined=False
383 )
384 self.device = "cpu"
385 self.layout = "HWC"
386 self.pos_size_iter = pos_size_iter
387
388 self.input = ops.readers.Caffe(path=caffe_db_folder, random_shuffle=False)
389 self.decode = ops.decoders.Image(device="cpu", output_type=types.RGB)
390
391 self.input_crop_pos = ops.ExternalSource()
392 self.input_crop_size = ops.ExternalSource()
393
394 function = partial(
395 slice_func_helper, axes, axis_names, self.layout, normalized_anchor, normalized_shape
396 )
397 self.slice = ops.PythonFunction(function=function, output_layouts="HWC")
398
399 def define_graph(self):
400 imgs, _ = self.input()
401 imgs = self.decode(imgs)
402 self.crop_pos = self.input_crop_pos()
403 self.crop_size = self.input_crop_size()
404 out = self.slice(imgs, self.crop_pos, self.crop_size)
405 return out
406
407 def iter_setup(self):
408 crop_pos, crop_size = self.pos_size_iter.next()
409 self.feed_input(self.crop_pos, crop_pos)
410 self.feed_input(self.crop_size, crop_size)
411
412
413def check_slice_synth_data_vs_numpy(

Callers 1

check_slice_vs_numpyFunction · 0.85

Calls

no outgoing calls

Tested by 1

check_slice_vs_numpyFunction · 0.68