Closed qihang720 closed 9 months ago
Hi @qihang720 ,
I'm not sure I've understood your question. I assume you'd like to put together a pipeline, where as input you have a batch of images and every such image will be cropped, but according to different position. Assuming it's for DALI Backend, here's the example:
W = 224
H = 224
@pipeline_def
def pipe():
enc = fn.external_source(name="ENC_IMAGE")
crop_x = fn.external_source(name="CROP_X")
crop_y = fn.external_source(name="CROP_Y")
dec = fn.decoders.image(enc)
return fn.crop(dec, crop_pos_x=crop_x, crop_pos_y=crop_y, crop=(H, W))
The explanation of crop_pos_x
and crop_pos_y
arguments you can find in fn.crop
documentation. In CROP_X
and CROP_Y
inputs, Client shall send a tensor with values determining cropping position. Please refer to documentation for the details.
Alternatively, you can use fn.crop_mirror_normalize
operator, if you like to combine cropping with other operation.
Hi @qihang720 ,
I'm not sure I've understood your question. I assume you'd like to put together a pipeline, where as input you have a batch of images and every such image will be cropped, but according to different position. Assuming it's for DALI Backend, here's the example:
W = 224 H = 224 @pipeline_def def pipe(): enc = fn.external_source(name="ENC_IMAGE") crop_x = fn.external_source(name="CROP_X") crop_y = fn.external_source(name="CROP_Y") dec = fn.decoders.image(enc) return fn.crop(dec, crop_pos_x=crop_x, crop_pos_y=crop_y, crop=(H, W))
The explanation of
crop_pos_x
andcrop_pos_y
arguments you can find infn.crop
documentation. InCROP_X
andCROP_Y
inputs, Client shall send a tensor with values determining cropping position. Please refer to documentation for the details.Alternatively, you can use
fn.crop_mirror_normalize
operator, if you like to combine cropping with other operation.
Thanks for your help, this is exactly the answer I want!
In my situation, I have to use yolo detected to crop different rect in original images, so how can I use dali to crop it.