MadryLab / robustness

A library for experimenting with, training and evaluating neural networks, with a focus on adversarial robustness.
MIT License
903 stars 181 forks source link

Can't load 'densenet121" #102

Open carlamao opened 3 years ago

carlamao commented 3 years ago

Is the documentation up to date? Because i cant seem to load 'densenet121' using this code, which works for resnet50:

model  = robustness.imagenet_models.resnet50(pretrained=True, num_classes=1000)

When I try to run

model  = robustness.imagenet_models.densenet121(pretrained=True, num_classes=1000)

I get the following error

AttributeError: module 'robustness.imagenet_models' has no attribute 'densenet121'
Hadisalman commented 2 years ago

@carlamao That's not how you should be loading models in our library. You should instead be doing this

from robustness import model_utils, datasets

ds = datasets.ImageNet(PATH)
model, checkpoint = model_utils.make_and_restore_model(arch='densenet121', dataset=ds)

And this should load densenet121 fine.