Python Runner on Linux: Squash not Crop

Is there a way to squash the image instead of cropping the image. get_features_from_image() crops the image. The Data Input Block in EI Studio allows squashing.

with ImageImpulseRunner("demo-linux-x86_64-v2023.eim") as runner:
   features, cropped = runner.get_features_from_image(img)

Hello @MMarcial,

Good question, we’ve been speaking about that in the past but I’m not sure it’s been implemented.
Let me have a deeper look at the code, if it’s not I’ll create an issue.



Hello @MMarcial,

So indeed, it is missing from the function:

I have not tried the following modification but that’s how I’d do it:


resized = cv2.resize(img, resize_size, interpolation = cv2.INTER_AREA)


resized = cv2.resize(img, (EI_CLASSIFIER_INPUT_WIDTH, IEI_CLASSIFIER_INPUT_HEIGHT), interpolation = cv2.INTER_AREA)

Feel free to use other resize method but I’ve figured over time that INTER_AREA is usually the one giving the best results/performance.

Then get rid of the crop conditions below (between lines 93 and 111).

Finally just use:

cropped = resized

Let me know if that works, I’ll create an internal issue so we can natively support that.