Skip to content

added sample code for fasterrcnn_resnet50_fpn (optional) #796

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

Merged
merged 7 commits into from
Jan 17, 2020

Conversation

prajjwal1
Copy link
Contributor

Discussed here.

@netlify
Copy link

netlify bot commented Dec 20, 2019

Deploy preview for pytorch-tutorials-preview ready!

Built with commit fe6080f

https://deploy-preview-796--pytorch-tutorials-preview.netlify.com

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I would rephrase the title of the section, because it can be misleading in some cases.

Also, there are some lint errors and extra spaces, can you fix those?

---------------------------

Before iterating over the dataset, it's always good to see what the model
expects during training and inference time with random tensors.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something we should be careful about: if we have batch normalization layers in the model (which is not the case for detection models because we freeze the batch norm layers, but happens in classification), feeding randomly-initialized data will affect the batch norm statistics, leading to potentially unexpected results

Copy link
Contributor Author

@prajjwal1 prajjwal1 Jan 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now changed the code from using random tensors to sampled data from the actual dataset. This will fix the batch norm stats issue. This is not what I had intended earlier, I just wanted to show what the model actually requires and how one can reproduce the output from model by passing random data because most users would not peek inside engine.py to learn what's happening initially. But you're right, batch norm stats would be calculated incorrectly as per previous commit. I guess this will be fine.

for i in range(len(images)):
d = {}
d['boxes'] = boxes[i]
d['labels'] = labels[i].type(torch.int64)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of .type is not encouraged (it's legacy), and instead we should use .to. See my fixes (including lint fixes) in pytorch/vision#1713

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. I've fixed it.

@prajjwal1
Copy link
Contributor Author

Let me know, if this seems fine.

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@prajjwal1
Copy link
Contributor Author

prajjwal1 commented Jan 9, 2020

Thanks, how can I fix the tests ?

@prajjwal1
Copy link
Contributor Author

@brianjo Can you please merge it ?

@brianjo
Copy link
Contributor

brianjo commented Jan 10, 2020

@brianjo Can you please merge it ?

Hi @prajjwal1, @yf225 and I are working on fixing the build right now and I'll rebase and merge this one when we get that going. Thanks!

@prajjwal1
Copy link
Contributor Author

@yf225 , Can you please have a look at this ? Can this be merged now. I'll close the issue in torchvision if it's merged.

@yf225
Copy link
Contributor

yf225 commented Jan 17, 2020

@prajjwal1 I believe all build jobs passed on this PR. @brianjo Do you think we can merge this PR?

@brianjo
Copy link
Contributor

brianjo commented Jan 17, 2020

@prajjwal1 I believe all build jobs passed on this PR. @brianjo Do you think we can merge this PR?

Will do. Still working through a Netlify issue, but this looks good. I'll rebase it first, but I'll get it in when it passes again.

@brianjo brianjo merged commit 8244bff into pytorch:master Jan 17, 2020
@prajjwal1
Copy link
Contributor Author

Thanks !

rodrigo-techera pushed a commit to Experience-Monks/tutorials that referenced this pull request Nov 29, 2021
added sample code for fasterrcnn_resnet50_fpn (optional)
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 this pull request may close these issues.

4 participants