Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image should be first transformed and only then used for the prediction #3

Open
tugot17 opened this issue Sep 4, 2020 · 3 comments · May be fixed by #4
Open

Image should be first transformed and only then used for the prediction #3

tugot17 opened this issue Sep 4, 2020 · 3 comments · May be fixed by #4

Comments

@tugot17
Copy link

tugot17 commented Sep 4, 2020

Describe the bug
Before conducting the prediction the image should be Resized to the original training size and then Normalized the data comes from the same distribution as training data

To Reproduce
In app.py go to the line 223

eval_ds = Dataset.from_images([image])
batch, samples = faster_rcnn.build_infer_batch(eval_ds)
preds = faster_rcnn.predict(
        model=model, batch=batch, detection_threshold=confidence_threshold)

How to fix

Add the transformation while creating the dataset

transformations = tfms.A.Adapter([tfms.A.Resize(384, 384), tfms.A.Normalize()])
eval_ds = Dataset.from_images([image], transformations)
batch, samples = faster_rcnn.build_infer_batch(eval_ds)
preds = faster_rcnn.predict(
model=model, batch=batch, detection_threshold=confidence_threshold)
@oke-aditya
Copy link
Contributor

oke-aditya commented Sep 4, 2020

Yes, we can add these Test Time Transforms too.
Thought it should work fine without these. Since Faster RCNN uses Generalized RCNN transforms that works for image of any size.

Can you open a PR as well @tugot17 ? If not possible, don't worry I will fix it up.

@tugot17
Copy link
Author

tugot17 commented Sep 4, 2020

I think the "domain" for not Normalized images is different and it may cause the predictor to not work properly.
I opened the PR #4

@oke-aditya
Copy link
Contributor

Can cause error, though it hasn't caused yet. But defensive programming is better.

@oke-aditya oke-aditya linked a pull request Sep 4, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants