How to resize image to bounding box?

How can i resize image to bounding box?
I mean dynamically set (xmin, ymin, xmax, ymax) values to all images, for future model training. I think transforms.Resize() can help me, but Resize() only takes two arguments and its not accurate to bounding box

seems like there are no way to crop it with pytorch, i’ll use Pillow lib.

Note that cropping can be expressed as a slicing index operation (e.g., given an image in CHW format you can just do crop = image[:, ymin:ymax, xmin:xmax] to crop and then call resize if necessary).