Spaces:
Runtime error
Runtime error
Upload models with huggingface_hub
Browse files- models/download_models.py +31 -0
- models/nin_imagenet.pth +3 -0
- models/vgg16-00b39a1b.pth +3 -0
- models/vgg19-d01eb7cb.pth +3 -0
models/download_models.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from os import path
|
3 |
+
from sys import version_info
|
4 |
+
from collections import OrderedDict
|
5 |
+
from torch.utils.model_zoo import load_url
|
6 |
+
|
7 |
+
|
8 |
+
# Download the VGG-19 model and fix the layer names
|
9 |
+
print("Downloading the VGG-19 model")
|
10 |
+
sd = load_url("https://web.eecs.umich.edu/~justincj/models/vgg19-d01eb7cb.pth")
|
11 |
+
map = {'classifier.1.weight':u'classifier.0.weight', 'classifier.1.bias':u'classifier.0.bias', 'classifier.4.weight':u'classifier.3.weight', 'classifier.4.bias':u'classifier.3.bias'}
|
12 |
+
sd = OrderedDict([(map[k] if k in map else k,v) for k,v in sd.items()])
|
13 |
+
torch.save(sd, path.join("models", "vgg19-d01eb7cb.pth"))
|
14 |
+
|
15 |
+
# Download the VGG-16 model and fix the layer names
|
16 |
+
print("Downloading the VGG-16 model")
|
17 |
+
sd = load_url("https://web.eecs.umich.edu/~justincj/models/vgg16-00b39a1b.pth")
|
18 |
+
map = {'classifier.1.weight':u'classifier.0.weight', 'classifier.1.bias':u'classifier.0.bias', 'classifier.4.weight':u'classifier.3.weight', 'classifier.4.bias':u'classifier.3.bias'}
|
19 |
+
sd = OrderedDict([(map[k] if k in map else k,v) for k,v in sd.items()])
|
20 |
+
torch.save(sd, path.join("models", "vgg16-00b39a1b.pth"))
|
21 |
+
|
22 |
+
# Download the NIN model
|
23 |
+
print("Downloading the NIN model")
|
24 |
+
if version_info[0] < 3:
|
25 |
+
import urllib
|
26 |
+
urllib.URLopener().retrieve("https://raw.githubusercontent.com/ProGamerGov/pytorch-nin/master/nin_imagenet.pth", path.join("models", "nin_imagenet.pth"))
|
27 |
+
else:
|
28 |
+
import urllib.request
|
29 |
+
urllib.request.urlretrieve("https://raw.githubusercontent.com/ProGamerGov/pytorch-nin/master/nin_imagenet.pth", path.join("models", "nin_imagenet.pth"))
|
30 |
+
|
31 |
+
print("All models have been successfully downloaded")
|
models/nin_imagenet.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:40e4a6ae31ab31cb2f50fb45c9974fc7b5530d716899c77196cd01b61f33160e
|
3 |
+
size 30383343
|
models/vgg16-00b39a1b.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2007cdad2519a9bbecdf5cd3c54145237502349a194e0d0a41a826e5a277c187
|
3 |
+
size 553438853
|
models/vgg19-d01eb7cb.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dd893d447ece014ad32d71b8d32b1e0b5c09b912a2866990c286fdeebd368d74
|
3 |
+
size 574679411
|