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

code for visualization in the object detection tutorial #1610

Closed
isalirezag opened this issue Nov 25, 2019 · 4 comments
Closed

code for visualization in the object detection tutorial #1610

isalirezag opened this issue Nov 25, 2019 · 4 comments

Comments

@isalirezag
Copy link

isalirezag commented Nov 25, 2019

At the end of the object detection tutorial it visualizes the masks.
can you please provide the code for that task? or guide how to do it?

@isalirezag isalirezag changed the title mask mAP and visualization for the tutorial code for mask mAP and visualization for the object detection tutorial Nov 25, 2019
@isalirezag isalirezag changed the title code for mask mAP and visualization for the object detection tutorial code for visualization in the object detection tutorial Nov 25, 2019
@fmassa
Copy link
Member

fmassa commented Dec 2, 2019

Hi,

The code I used for the masks uses OpenCV (which torchvision doesn't use as a dependency), and that's one of the reasons why I didn't share that code yet.

Here are the scripts: https://gist.github.com/fmassa/d802c684512bcc99f54b714f10c96872

I used something like the following to visualize

model = torchvision.models.detection.keypointrcnn_resnet50_fpn(pretrained=True)
model.cuda()
model.eval();

# img is a PIL Image
result, output, top_pred = predict(img, model)
plt.imshow(Image.fromarray(result[:, :, [2, 1, 0]]))

Let me know if you have questions. I think it makes sense to add those functions somewhere in torchvision, but I'm not yet sure where

@mattans
Copy link

mattans commented Jul 5, 2020

@fmassa , since you used a pretrained model, didn't you need to normalize your PIL image before?

@fmassa
Copy link
Member

fmassa commented Jul 7, 2020

Hi @mattans

Normalization for the detection models happen inside the model, see

image = self.normalize(image)

@mattans
Copy link

mattans commented Jul 7, 2020

Great, thanks.
Linking to #2397 (comment) as it's related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants