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

Update calls to torch.hub.* to use trust_repo=True. #281

Merged
merged 6 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datvuthanh_hybridnets.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ This example loads the pretrained **HybridNets** model and passes an image for i
import torch

# load model
model = torch.hub.load('datvuthanh/hybridnets', 'hybridnets', pretrained=True)
model = torch.hub.load('datvuthanh/hybridnets', 'hybridnets', pretrained=True, trust_repo=True)

#inference
img = torch.randn(1,3,640,384)
Expand Down
2 changes: 1 addition & 1 deletion huggingface_pytorch-transformers.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The tokenizer object allows the conversion from character strings to tokens unde

```py
import torch
tokenizer = torch.hub.load('huggingface/pytorch-transformers', 'tokenizer', 'bert-base-uncased') # Download vocabulary from S3 and cache.
tokenizer = torch.hub.load('huggingface/pytorch-transformers', trust_repo=True, 'tokenizer', 'bert-base-uncased') # Download vocabulary from S3 and cache.
tokenizer = torch.hub.load('huggingface/pytorch-transformers', 'tokenizer', './test/bert_saved_model/') # E.g. tokenizer was saved using `save_pretrained('./test/saved_model/')`
```

Expand Down
2 changes: 1 addition & 1 deletion hustvl_yolop.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ This example loads the pretrained **YOLOP** model and passes an image for infere
import torch

# load model
model = torch.hub.load('hustvl/yolop', 'yolop', pretrained=True)
model = torch.hub.load('hustvl/yolop', 'yolop', trust_repo=True, pretrained=True)

#inference
img = torch.randn(1,3,640,640)
Expand Down
2 changes: 1 addition & 1 deletion intelisl_midas_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ model_type = "DPT_Large" # MiDaS v3 - Large (highest accuracy, slowest i
#model_type = "DPT_Hybrid" # MiDaS v3 - Hybrid (medium accuracy, medium inference speed)
#model_type = "MiDaS_small" # MiDaS v2.1 - Small (lowest accuracy, highest inference speed)

midas = torch.hub.load("intel-isl/MiDaS", model_type)
midas = torch.hub.load("intel-isl/MiDaS", model_type, trust_repo=True)
```
Move model to GPU if available
```python
Expand Down
2 changes: 1 addition & 1 deletion mateuszbuda_brain-segmentation-pytorch_unet.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ demo-model-link: https://huggingface.co/spaces/pytorch/U-NET-for-brain-MRI

```python
import torch
model = torch.hub.load('mateuszbuda/brain-segmentation-pytorch', 'unet',
model = torch.hub.load('mateuszbuda/brain-segmentation-pytorch', 'unet', trust_repo=True,
in_channels=3, out_channels=1, init_features=32, pretrained=True)

```
Expand Down
2 changes: 1 addition & 1 deletion nicolalandro_ntsnet-cub200_ntsnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ demo-model-link: https://huggingface.co/spaces/pytorch/NTSNET

```python
import torch
model = torch.hub.load('nicolalandro/ntsnet-cub200', 'ntsnet', pretrained=True,
model = torch.hub.load('nicolalandro/ntsnet-cub200', 'ntsnet', trust_repo=True, pretrained=True,
**{'topN': 6, 'device':'cpu', 'num_classes': 200})
```

Expand Down
2 changes: 1 addition & 1 deletion nvidia_deeplearningexamples_efficientnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ You can choose among the following models:

There are also quantized version of the models, but they require nvidia container. See [quantized models](https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch/Classification/ConvNets/efficientnet#quantization)
```python
efficientnet = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_efficientnet_b0', pretrained=True)
efficientnet = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_efficientnet_b0', trust_repo=True, pretrained=True)
utils = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_convnets_processing_utils')

efficientnet.eval().to(device)
Expand Down
2 changes: 1 addition & 1 deletion nvidia_deeplearningexamples_resnet50.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ print(f'Using {device} for inference')

Load the model pretrained on IMAGENET dataset.
```python
resnet50 = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_resnet50', pretrained=True)
resnet50 = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_resnet50', pretrained=True, trust_repo=True)
utils = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_convnets_processing_utils')

resnet50.eval().to(device)
Expand Down
2 changes: 1 addition & 1 deletion nvidia_deeplearningexamples_resnext.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ print(f'Using {device} for inference')

Load the model pretrained on IMAGENET dataset.
```python
resneXt = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_resneXt')
resneXt = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_resneXt', trust_repo=True)
utils = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_convnets_processing_utils')

resneXt.eval().to(device)
Expand Down
2 changes: 1 addition & 1 deletion nvidia_deeplearningexamples_se-resnext.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ print(f'Using {device} for inference')

Load the model pretrained on IMAGENET dataset.
```python
resneXt = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_se_resnext101_32x4d')
resneXt = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_se_resnext101_32x4d', trust_repo=True)
utils = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_convnets_processing_utils')

resneXt.eval().to(device)
Expand Down
2 changes: 1 addition & 1 deletion nvidia_deeplearningexamples_ssd.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pip install numpy scipy scikit-image matplotlib
Load an SSD model pretrained on COCO dataset, as well as a set of utility methods for convenient and comprehensive formatting of input and output of the model.
```python
import torch
ssd_model = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_ssd')
ssd_model = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_ssd', trust_repo=True)
utils = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_ssd_processing_utils')
```

Expand Down
2 changes: 1 addition & 1 deletion nvidia_deeplearningexamples_tacotron2.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ apt-get install -y libsndfile1
Load the Tacotron2 model pre-trained on [LJ Speech dataset](https://keithito.com/LJ-Speech-Dataset/) and prepare it for inference:
```python
import torch
tacotron2 = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_tacotron2', model_math='fp16')
tacotron2 = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_tacotron2', trust_repo=True, model_math='fp16')
tacotron2 = tacotron2.to('cuda')
tacotron2.eval()
```
Expand Down
2 changes: 1 addition & 1 deletion nvidia_deeplearningexamples_waveglow.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ apt-get install -y libsndfile1
Load the WaveGlow model pre-trained on [LJ Speech dataset](https://keithito.com/LJ-Speech-Dataset/)
```python
import torch
waveglow = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_waveglow', model_math='fp32')
waveglow = torch.hub.load('NVIDIA/DeepLearningExamples:torchhub', 'nvidia_waveglow', trust_repo=True, model_math='fp32')
```

Prepare the WaveGlow model for inference
Expand Down
2 changes: 1 addition & 1 deletion pytorch_vision_ghostnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ demo-model-link: https://huggingface.co/spaces/pytorch/GhostNet

```python
import torch
model = torch.hub.load('huawei-noah/ghostnet', 'ghostnet_1x', pretrained=True)
model = torch.hub.load('huawei-noah/ghostnet', 'ghostnet_1x', pretrained=True, trust_repo=True)
model.eval()
```

Expand Down
2 changes: 1 addition & 1 deletion pytorch_vision_hardnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ demo-model-link: https://huggingface.co/spaces/pytorch/HardNet

```python
import torch
model = torch.hub.load('PingoLH/Pytorch-HarDNet', 'hardnet68', pretrained=True)
model = torch.hub.load('PingoLH/Pytorch-HarDNet', 'hardnet68', pretrained=True, trust_repo=True)
# or any of these variants
# model = torch.hub.load('PingoLH/Pytorch-HarDNet', 'hardnet85', pretrained=True)
# model = torch.hub.load('PingoLH/Pytorch-HarDNet', 'hardnet68ds', pretrained=True)
Expand Down
2 changes: 1 addition & 1 deletion pytorch_vision_ibnnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ demo-model-link: https://huggingface.co/spaces/pytorch/IBN-Net

```python
import torch
model = torch.hub.load('XingangPan/IBN-Net', 'resnet50_ibn_a', pretrained=True)
model = torch.hub.load('XingangPan/IBN-Net', 'resnet50_ibn_a', pretrained=True, trust_repo=True)
model.eval()
```

Expand Down
4 changes: 2 additions & 2 deletions pytorch_vision_meal_v2.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
load(---
layout: hub_detail
background-class: hub-background
body-class: hub
Expand Down Expand Up @@ -27,7 +27,7 @@ We require one additional Python dependency
import torch
# list of models: 'mealv1_resnest50', 'mealv2_resnest50', 'mealv2_resnest50_cutmix', 'mealv2_resnest50_380x380', 'mealv2_mobilenetv3_small_075', 'mealv2_mobilenetv3_small_100', 'mealv2_mobilenet_v3_large_100', 'mealv2_efficientnet_b0'
# load pretrained models, using "mealv2_resnest50_cutmix" as an example
model = torch.hub.load('szq0214/MEAL-V2','meal_v2', 'mealv2_resnest50_cutmix', pretrained=True)
model = torch.hub.load('szq0214/MEAL-V2','meal_v2', 'mealv2_resnest50_cutmix', pretrained=True, trust_repo=True)
model.eval()
```

Expand Down
2 changes: 1 addition & 1 deletion pytorch_vision_proxylessnas.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ demo-model-link: https://huggingface.co/spaces/pytorch/ProxylessNAS
import torch
target_platform = "proxyless_cpu"
# proxyless_gpu, proxyless_mobile, proxyless_mobile14 are also avaliable.
model = torch.hub.load('mit-han-lab/ProxylessNAS', target_platform, pretrained=True)
model = torch.hub.load('mit-han-lab/ProxylessNAS', target_platform, pretrained=True, trust_repo=True)
model.eval()
```

Expand Down
4 changes: 2 additions & 2 deletions pytorch_vision_resnest.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ demo-model-link: https://huggingface.co/spaces/pytorch/ResNeSt
```python
import torch
# get list of models
torch.hub.list('zhanghang1989/ResNeSt', force_reload=True)
torch.hub.list('zhanghang1989/ResNeSt', force_reload=True, trust_repo=True)
# load pretrained models, using ResNeSt-50 as an example
model = torch.hub.load('zhanghang1989/ResNeSt', 'resnest50', pretrained=True)
model = torch.hub.load('zhanghang1989/ResNeSt', 'resnest50', pretrained=True, trust_repo=True)
model.eval()
```

Expand Down
2 changes: 1 addition & 1 deletion scripts/run_pytorch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ do
sed -n '/^```python/,/^```/ p' < $f | sed '/^```/ d' > $out_py
done

pytest --junitxml=test-results/junit.xml test_run_python_code.py -vv
pytest --junitxml=test-results/junit.xml test_run_python_code.py -vv -r all -s
2 changes: 1 addition & 1 deletion sigsep_open-unmix-pytorch_umx.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pip install -q torchaudio
import torch

# loading umxhq four target separator
separator = torch.hub.load('sigsep/open-unmix-pytorch', 'umxhq')
separator = torch.hub.load('sigsep/open-unmix-pytorch', 'umxhq', trust_repo=True)

# generate random audio
# ... with shape (nb_samples, nb_channels, nb_timesteps)
Expand Down
1 change: 1 addition & 0 deletions snakers4_silero-models_stt.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ device = torch.device('cpu') # gpu also works, but our models are fast enough f

model, decoder, utils = torch.hub.load(repo_or_dir='snakers4/silero-models',
model='silero_stt',
trust_repo=True,
language='en', # also available 'de', 'es'
device=device)
(read_batch, split_into_batches,
Expand Down
1 change: 1 addition & 0 deletions snakers4_silero-models_tts.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ speaker = 'lj_16khz'
device = torch.device('cpu')
model, symbols, sample_rate, example_text, apply_tts = torch.hub.load(repo_or_dir='snakers4/silero-models',
model='silero_tts',
trust_repo=True,
language=language,
speaker=speaker)
model = model.to(device) # gpu or cpu
Expand Down
3 changes: 2 additions & 1 deletion snakers4_silero-vad_language.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ torch.hub.download_url_to_file('https://models.silero.ai/vad_models/de.wav', 'de

model, utils = torch.hub.load(repo_or_dir='snakers4/silero-vad',
model='silero_lang_detector',
force_reload=True)
force_reload=True,
trust_repo=True)

get_language, read_audio, *_ = utils

Expand Down
3 changes: 2 additions & 1 deletion snakers4_silero-vad_number.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ torch.hub.download_url_to_file('https://models.silero.ai/vad_models/en_num.wav',

model, utils = torch.hub.load(repo_or_dir='snakers4/silero-vad',
model='silero_number_detector',
force_reload=True)
force_reload=True,
trust_repo=True)

(get_number_ts,
_, read_audio,
Expand Down
3 changes: 2 additions & 1 deletion snakers4_silero-vad_vad.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ torch.hub.download_url_to_file('https://models.silero.ai/vad_models/en.wav', 'en

model, utils = torch.hub.load(repo_or_dir='snakers4/silero-vad',
model='silero_vad',
force_reload=True)
force_reload=True,
trust_repo=True)

(get_speech_timestamps,
_, read_audio,
Expand Down
2 changes: 1 addition & 1 deletion ultralytics_yolov5.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ This example loads a pretrained **YOLOv5s** model and passes an image for infere
import torch

# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True, trust_repo=True)

# Images
imgs = ['https://ultralytics.com/images/zidane.jpg'] # batch of images
Expand Down