Skip to content

Commit bbadbd4

Browse files
committed
Merge branch 'master' of github.com:pytorch/hub into set_trust_repo
2 parents 717726b + ed58d27 commit bbadbd4

16 files changed

+128
-91
lines changed

.circleci/config.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@ update_submodule: &update_submodule
88
jobs:
99
run_torchhub:
1010
machine:
11-
image: ubuntu-1604:201903-01
11+
image: ubuntu-2004-cuda-11.4:202110-01
1212
resource_class: gpu.nvidia.small
1313
steps:
1414
- checkout
15-
- run:
16-
name: Setup CI environment
17-
command: ./scripts/setup_ci.sh
1815
- run:
1916
name: Install Deps
20-
command: ./scripts/install_basics.sh; ./scripts/install.sh
17+
command: ./scripts/install_conda.sh; ./scripts/install_deps.sh
2118
- run:
2219
name: Sanity Check
2320
command: . ~/miniconda3/etc/profile.d/conda.sh; conda activate base; python scripts/sanity_check.py

facebookresearch_pytorch-gan-zoo_pgan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ Progressive Growing of GANs is a method developed by Karras et. al. [1] in 2017
6767

6868
### References
6969

70-
- [Progressive Growing of GANs for Improved Quality, Stability, and Variation](https://arxiv.org/abs/1710.10196)
70+
[1] Tero Karras et al, "Progressive Growing of GANs for Improved Quality, Stability, and Variation" https://arxiv.org/abs/1710.10196

facebookresearch_pytorchvideo_resnet.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,12 @@ print("Top 5 predicted labels: %s" % ", ".join(pred_class_names))
160160
### Model Description
161161
The model architecture is based on [1] with pretrained weights using the 8x8 setting
162162
on the Kinetics dataset.
163+
163164
| arch | depth | frame length x sample rate | top 1 | top 5 | Flops (G) | Params (M) |
164-
| --------------- | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- |
165+
| --------------- | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- |
165166
| Slow | R50 | 8x8 | 74.58 | 91.63 | 54.52 | 32.45 |
166167

167168

168169
### References
169170
[1] Christoph Feichtenhofer et al, "SlowFast Networks for Video Recognition"
170-
https://arxiv.org/pdf/1812.03982.pdf
171+
https://arxiv.org/pdf/1812.03982.pdf

facebookresearch_semi-supervised-ImageNet1K-models_resnext.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ demo-model-link: https://huggingface.co/spaces/pytorch/semi-supervised-ImageNet1
2020
```python
2121
import torch
2222

23-
# === SEMI-WEAKLY SUPERVISED MODELSP RETRAINED WITH 940 HASHTAGGED PUBLIC CONTENT ===
23+
# === SEMI-WEAKLY SUPERVISED MODELS PRETRAINED WITH 940 HASHTAGGED PUBLIC CONTENT ===
2424
model = torch.hub.load('facebookresearch/semi-supervised-ImageNet1K-models', 'resnet18_swsl')
2525
# model = torch.hub.load('facebookresearch/semi-supervised-ImageNet1K-models', 'resnet50_swsl')
2626
# model = torch.hub.load('facebookresearch/semi-supervised-ImageNet1K-models', 'resnext50_32x4d_swsl')

images/snnmlp.png

137 KB
Loading

nvidia_deeplearningexamples_resnet50.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ The ***ResNet50 v1.5*** model is a modified version of the [original ResNet50 v1
2525
The difference between v1 and v1.5 is that, in the bottleneck blocks which requires
2626
downsampling, v1 has stride = 2 in the first 1x1 convolution, whereas v1.5 has stride = 2 in the 3x3 convolution.
2727

28-
This difference makes ResNet50 v1.5 slightly more accurate (\~0.5% top1) than v1, but comes with a smallperformance drawback (\~5% imgs/sec).
28+
This difference makes ResNet50 v1.5 slightly more accurate (\~0.5% top1) than v1, but comes with a small performance drawback (\~5% imgs/sec).
2929

3030
The model is initialized as described in [Delving deep into rectifiers: Surpassing human-level performance on ImageNet classification](https://arxiv.org/pdf/1502.01852.pdf)
3131

3232
This model is trained with mixed precision using Tensor Cores on Volta, Turing, and the NVIDIA Ampere GPU architectures. Therefore, researchers can get results over 2x faster than training without Tensor Cores, while experiencing the benefits of mixed precision training. This model is tested against each NGC monthly container release to ensure consistent accuracy and performance over time.
3333

34-
Note that the ResNet50 v1.5 model can be deployed for inference on the [NVIDIA Triton Inference Server](https://github.com/NVIDIA/trtis-inference-server) using TorchScript, ONNX Runtime or TensorRT as an execution backend. For details check [NGC](https://ngc.nvidia.com/catalog/resources/nvidia:resnet_for_triton_from_pytorch)
34+
Note that the ResNet50 v1.5 model can be deployed for inference on the [NVIDIA Triton Inference Server](https://github.com/triton-inference-server/server) using TorchScript, ONNX Runtime or TensorRT as an execution backend. For details check [NGC](https://ngc.nvidia.com/catalog/resources/nvidia:resnet_for_triton_from_pytorch)
3535

3636

3737
### Example
@@ -81,7 +81,7 @@ batch = torch.cat(
8181
).to(device)
8282
```
8383

84-
Run inference. Use `pick_n_best(predictions=output, n=topN)` helepr function to pick N most probably hypothesis according to the model.
84+
Run inference. Use `pick_n_best(predictions=output, n=topN)` helper function to pick N most probably hypothesis according to the model.
8585
```python
8686
with torch.no_grad():
8787
output = torch.nn.functional.softmax(resnet50(batch), dim=1)
@@ -112,4 +112,4 @@ and/or [NGC](https://ngc.nvidia.com/catalog/resources/nvidia:resnet_50_v1_5_for_
112112
- [model on github](https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch/Classification/ConvNets/resnet50v1.5)
113113
- [model on NGC](https://ngc.nvidia.com/catalog/resources/nvidia:resnet_50_v1_5_for_pytorch)
114114
- [pretrained model on NGC](https://ngc.nvidia.com/catalog/models/nvidia:resnet50_pyt_amp)
115-
115+

nvidia_deeplearningexamples_resnext.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This model is trained with mixed precision using Tensor Cores on Volta, Turing,
2828

2929
We use [NHWC data layout](https://pytorch.org/tutorials/intermediate/memory_format_tutorial.html) when training using Mixed Precision.
3030

31-
Note that the ResNeXt101-32x4d model can be deployed for inference on the [NVIDIA Triton Inference Server](https://github.com/NVIDIA/trtis-inference-server) using TorchScript, ONNX Runtime or TensorRT as an execution backend. For details check [NGC](https://ngc.nvidia.com/catalog/resources/nvidia:resnext_for_triton_from_pytorch)
31+
Note that the ResNeXt101-32x4d model can be deployed for inference on the [NVIDIA Triton Inference Server](https://github.com/triton-inference-server/server) using TorchScript, ONNX Runtime or TensorRT as an execution backend. For details check [NGC](https://ngc.nvidia.com/catalog/resources/nvidia:resnext_for_triton_from_pytorch)
3232

3333
#### Model architecture
3434

@@ -87,7 +87,7 @@ batch = torch.cat(
8787
).to(device)
8888
```
8989

90-
Run inference. Use `pick_n_best(predictions=output, n=topN)` helepr function to pick N most probably hypothesis according to the model.
90+
Run inference. Use `pick_n_best(predictions=output, n=topN)` helper function to pick N most probably hypothesis according to the model.
9191
```python
9292
with torch.no_grad():
9393
output = torch.nn.functional.softmax(resneXt(batch), dim=1)

nvidia_deeplearningexamples_se-resnext.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ _Image source: [Squeeze-and-Excitation Networks](https://arxiv.org/pdf/1709.0150
3737
Image shows the architecture of SE block and where is it placed in ResNet bottleneck block.
3838

3939

40-
Note that the SE-ResNeXt101-32x4d model can be deployed for inference on the [NVIDIA Triton Inference Server](https://github.com/NVIDIA/trtis-inference-server) using TorchScript, ONNX Runtime or TensorRT as an execution backend. For details check [NGC](https://catalog.ngc.nvidia.com/orgs/nvidia/resources/se_resnext_for_triton_from_pytorch).
40+
Note that the SE-ResNeXt101-32x4d model can be deployed for inference on the [NVIDIA Triton Inference Server](https://github.com/triton-inference-server/server) using TorchScript, ONNX Runtime or TensorRT as an execution backend. For details check [NGC](https://catalog.ngc.nvidia.com/orgs/nvidia/resources/se_resnext_for_triton_from_pytorch).
4141

4242
### Example
4343

nvidia_deeplearningexamples_tacotron2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This implementation of Tacotron 2 model differs from the model described in the
2828

2929
In the example below:
3030
- pretrained Tacotron2 and Waveglow models are loaded from torch.hub
31-
- Tacotron2 generates mel spectrogram given tensor represantation of an input text ("Hello world, I missed you so much")
31+
- Given a tensor representation of the input text ("Hello world, I missed you so much"), Tacotron2 generates a Mel spectrogram as shown on the illustration
3232
- Waveglow generates sound given the mel spectrogram
3333
- the output sound is saved in an 'audio.wav' file
3434

nvidia_deeplearningexamples_waveglow.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The Tacotron 2 and WaveGlow model form a text-to-speech system that enables user
2626

2727
In the example below:
2828
- pretrained Tacotron2 and Waveglow models are loaded from torch.hub
29-
- Tacotron2 generates mel spectrogram given tensor represantation of an input text ("Hello world, I missed you so much")
29+
- Given a tensor representation of the input text ("Hello world, I missed you so much"), Tacotron2 generates a Mel spectrogram as shown on the illustration
3030
- Waveglow generates sound given the mel spectrogram
3131
- the output sound is saved in an 'audio.wav' file
3232

@@ -98,4 +98,4 @@ For detailed information on model input and output, training recipies, inference
9898
- [Natural TTS Synthesis by Conditioning WaveNet on Mel Spectrogram Predictions](https://arxiv.org/abs/1712.05884)
9999
- [WaveGlow: A Flow-based Generative Network for Speech Synthesis](https://arxiv.org/abs/1811.00002)
100100
- [Tacotron2 and WaveGlow on NGC](https://ngc.nvidia.com/catalog/resources/nvidia:tacotron_2_and_waveglow_for_pytorch)
101-
- [Tacotron2 and Waveglow on github](https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch/SpeechSynthesis/Tacotron2)
101+
- [Tacotron2 and Waveglow on github](https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch/SpeechSynthesis/Tacotron2)

pytorch_vision_once_for_all.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ You can quickly load a supernet as following
2323

2424
```python
2525
import torch
26-
super_net_name = "ofa_supernet_resnet50"
26+
super_net_name = "ofa_supernet_mbv3_w10"
2727
# other options:
28-
# ofa_mbv3_d234_e346_k357_w1.0 /
29-
# ofa_mbv3_d234_e346_k357_w1.2 /
30-
# ofa_proxyless_d234_e346_k357_w1.3
28+
# ofa_supernet_resnet50 /
29+
# ofa_supernet_mbv3_w12 /
30+
# ofa_supernet_proxyless
3131

3232
super_net = torch.hub.load('mit-han-lab/once-for-all', super_net_name, pretrained=True).eval()
3333
```
@@ -60,25 +60,18 @@ import torch
6060

6161
# or load a architecture specialized for certain platform
6262
net_config = "resnet50D_MAC_4_1B"
63-
# other options
64-
65-
66-
67-
68-
69-
70-
71-
72-
73-
specialized_net = torch.hub.load('mit-han-lab/once-for-all', net_config, pretrained=True).eval()
63+
64+
specialized_net, image_size = torch.hub.load('mit-han-lab/once-for-all', net_config, pretrained=True)
65+
specialized_net.eval()
7466
```
7567

7668
More models and configurations can be found in [once-for-all/model-zoo](https://github.com/mit-han-lab/once-for-all#evaluate-1)
7769
and obtained through the following scripts
7870

7971
```python
8072
ofa_specialized_get = torch.hub.load('mit-han-lab/once-for-all', "ofa_specialized_get")
81-
model = ofa_specialized_get("flops@[email protected]_finetune@75", pretrained=True)
73+
model, image_size = ofa_specialized_get("flops@[email protected]_finetune@75", pretrained=True)
74+
model.eval()
8275
```
8376

8477
The model's prediction can be evalutaed by

pytorch_vision_snnmlp.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
layout: hub_detail
3+
background-class: hub-background
4+
body-class: hub
5+
title: SNNMLP
6+
summary: Brain-inspired Multilayer Perceptron with Spiking Neurons
7+
category: researchers
8+
image: snnmlp.png
9+
author: Huawei Noah's Ark Lab
10+
tags: [vision, scriptable]
11+
github-link: https://github.com/huawei-noah/Efficient-AI-Backbones
12+
github-id: huawei-noah/Efficient-AI-Backbones
13+
featured_image_1: snnmlp.png
14+
featured_image_2: no-image
15+
accelerator: cuda-optional
16+
order: 10
17+
---
18+
19+
```python
20+
import torch
21+
model = torch.hub.load('huawei-noah/Efficient-AI-Backbones', 'snnmlp_t', pretrained=True)
22+
# or
23+
# model = torch.hub.load('huawei-noah/Efficient-AI-Backbones', 'snnmlp_s', pretrained=True)
24+
# or
25+
# model = torch.hub.load('huawei-noah/Efficient-AI-Backbones', 'snnmlp_b', pretrained=True)
26+
model.eval()
27+
```
28+
29+
All pre-trained models expect input images normalized in the same way,
30+
i.e. mini-batches of 3-channel RGB images of shape `(3 x H x W)`, where `H` and `W` are expected to be at least `224`.
31+
The images have to be loaded in to a range of `[0, 1]` and then normalized using `mean = [0.485, 0.456, 0.406]`
32+
and `std = [0.229, 0.224, 0.225]`.
33+
34+
Here's a sample execution.
35+
36+
```python
37+
# Download an example image from the pytorch website
38+
import urllib
39+
url, filename = ("https://github.com/pytorch/hub/raw/master/dog.jpg", "dog.jpg")
40+
try: urllib.URLopener().retrieve(url, filename)
41+
except: urllib.request.urlretrieve(url, filename)
42+
```
43+
44+
```python
45+
# sample execution (requires torchvision)
46+
from PIL import Image
47+
from torchvision import transforms
48+
input_image = Image.open(filename)
49+
preprocess = transforms.Compose([
50+
transforms.Resize(256),
51+
transforms.CenterCrop(224),
52+
transforms.ToTensor(),
53+
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
54+
])
55+
input_tensor = preprocess(input_image)
56+
input_batch = input_tensor.unsqueeze(0) # create a mini-batch as expected by the model
57+
58+
# move the input and model to GPU for speed if available
59+
if torch.cuda.is_available():
60+
input_batch = input_batch.to('cuda')
61+
model.to('cuda')
62+
63+
with torch.no_grad():
64+
output = model(input_batch)
65+
# Tensor of shape 1000, with confidence scores over Imagenet's 1000 classes
66+
print(output[0])
67+
# The output has unnormalized scores. To get probabilities, you can run a softmax on it.
68+
print(torch.nn.functional.softmax(output[0], dim=0))
69+
70+
```
71+
72+
### Model Description
73+
74+
SNNMLP incorporates the mechanism of LIF neurons into the MLP models, to achieve better accuracy without extra FLOPs. We propose a full-precision LIF operation to communicate between patches, including horizontal LIF and vertical LIF in different directions. We also propose to use group LIF to extract better local features. With LIF modules, our SNNMLP model achieves 81.9%, 83.3% and 83.6% top-1 accuracy on ImageNet dataset with only 4.4G, 8.5G and 15.2G FLOPs, respectively.
75+
76+
The corresponding accuracy on ImageNet dataset with pretrained model is listed below.
77+
78+
| Model structure | #Parameters | FLOPs | Top-1 acc |
79+
| --------------- | ----------- | ----------- | ----------- |
80+
| SNNMLP Tiny | 28M | 4.4G | 81.88 |
81+
| SNNMLP Small | 50M | 8.5G | 83.30 |
82+
| SNNMLP Base | 88M | 15.2G | 85.59 |
83+
84+
85+
### References
86+
87+
You can read the full paper [here](https://arxiv.org/abs/2203.14679).
88+
```
89+
@inproceedings{li2022brain,
90+
title={Brain-inspired multilayer perceptron with spiking neurons},
91+
author={Li, Wenshuo and Chen, Hanting and Guo, Jianyuan and Zhang, Ziyang and Wang, Yunhe},
92+
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
93+
pages={783--793},
94+
year={2022}
95+
}
96+
```
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
#!/bin/bash
2-
set -e
3-
set -x
2+
set -ex
43

5-
# Install basics
6-
sudo apt-get install vim
7-
8-
# Install miniconda
94
CONDA=https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
105
filename=$(basename "$CONDA")
116
wget "$CONDA"
127
chmod +x "$filename"
13-
./"$filename" -b -u
8+
bash "$filename" -b -u
149

15-
# Force to use python3.8
1610
. ~/miniconda3/etc/profile.d/conda.sh
1711
conda activate base
1812
conda install -y python=3.8
19-
20-
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
#!/bin/bash
2-
set -e
3-
set -x
2+
set -ex
43

54
. ~/miniconda3/etc/profile.d/conda.sh
65
conda activate base
76

8-
conda install -y pytorch torchvision torchaudio -c pytorch-nightly
9-
7+
conda install -y pytorch torchvision torchaudio pytorch-cuda=11.6 -c pytorch-nightly -c nvidia
108
conda install -y pytest
119

1210
# Dependencies required to load models
13-
conda install -y regex pillow tqdm boto3 requests numpy\
14-
h5py scipy matplotlib unidecode ipython pyyaml
11+
conda install -y regex pillow tqdm boto3 requests numpy h5py scipy matplotlib unidecode ipython pyyaml
1512
conda install -y -c conda-forge librosa inflect
1613

1714
pip install -q fastBPE sacremoses sentencepiece subword_nmt editdistance
@@ -21,4 +18,4 @@ pip install -q hydra-core opencv-python fvcore
2118
pip install -q --upgrade google-api-python-client
2219
pip install pytorchvideo
2320
pip install -q prefetch_generator # yolop
24-
pip install -q pretrainedmodels efficientnet_pytorch # hybridnets
21+
pip install -q pretrainedmodels efficientnet_pytorch webcolors # hybridnets

scripts/install_nightlies.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

scripts/setup_ci.sh

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)