after Lesson 8, I am trying to build a classification model based on cropped images by bounding box.
I already have got a model which can predcit bounding box.
Are there any functions can crop images by bounding box before transformations or in transformations.
_, val_tfms = tfms_from_model(f_model, sz)
im = val_tfms(img)
result = to_np(model.model(VV(im[None])))
return [result[j] for j in [1,0,3,2]]
augs = [Lambda(lambda img: img.crop(cropbybbox(bbox_model,img))),
tfms = tfms_from_model(f_model, sz, aug_tfms=augs, crop_type=CropType.NO)
md = ImageClassifierData.from_csv(PATH, JPEGS, CSV, tfms=tfms)
In here, img is not a PIL object. I think it is a numpy array. So I can’t use crop method directly.