-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Conversation
Deploy preview for pytorch-tutorials-preview ready! Built with commit fe6080f https://deploy-preview-796--pytorch-tutorials-preview.netlify.com |
There was a problem hiding this 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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Let me know, if this seems fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Thanks, how can I fix the tests ? |
@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! |
@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. |
@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. |
Thanks ! |
added sample code for fasterrcnn_resnet50_fpn (optional)
Discussed here.