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

Read labels from the module, not from some random file #103

Open
simsong opened this issue Dec 13, 2022 · 0 comments
Open

Read labels from the module, not from some random file #103

simsong opened this issue Dec 13, 2022 · 0 comments

Comments

@simsong
Copy link

simsong commented Dec 13, 2022

Chapter 2 uses this code to get the model labels:

with open('../data/p1ch2/imagenet_classes.txt') as f:
    labels = [line.strip() for line in f.readlines()]

However, it is never made clear where the file imagenet_classes.txt comes from.

It turns out that they are already in torchvision.models:

from torchvision import models
labels = models.ResNet101_Weights.DEFAULT.meta['categories']

It would be useful to update the book to make this clear, or at least put it in the errata.

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

No branches or pull requests

1 participant