Skip to content

Commit db7e206

Browse files
committed
Put back torchhub section where it originally was
1 parent 9a306c1 commit db7e206

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

docs/source/models.rst

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,25 @@ behavior, such as batch normalization. To switch between these modes, use
120120
# Set model to eval mode
121121
model.eval()
122122
123+
Using models from Hub
124+
---------------------
125+
126+
Most pre-trained models can be accessed directly via PyTorch Hub without having TorchVision installed:
127+
128+
.. code:: python
129+
130+
import torch
131+
132+
# Option 1: passing weights param as string
133+
model = torch.hub.load("pytorch/vision", "resnet50", weights="IMAGENET1K_V2")
134+
135+
# Option 2: passing weights param as enum
136+
weights = torch.hub.load("pytorch/vision", "get_weight", weights="ResNet50_Weights.IMAGENET1K_V2")
137+
model = torch.hub.load("pytorch/vision", "resnet50", weights=weights)
138+
139+
The only exception to the above are the detection models included on
140+
:mod:`torchvision.models.detection`. These models require TorchVision
141+
to be installed because they depend on custom C++ operators.
123142

124143
Classification
125144
==============
@@ -494,23 +513,3 @@ The following Optical Flow models are available, with or without pre-trained
494513
:maxdepth: 1
495514

496515
models/raft
497-
498-
Using models from Hub
499-
=====================
500-
501-
Most pre-trained models can be accessed directly via PyTorch Hub without having TorchVision installed:
502-
503-
.. code:: python
504-
505-
import torch
506-
507-
# Option 1: passing weights param as string
508-
model = torch.hub.load("pytorch/vision", "resnet50", weights="IMAGENET1K_V2")
509-
510-
# Option 2: passing weights param as enum
511-
weights = torch.hub.load("pytorch/vision", "get_weight", weights="ResNet50_Weights.IMAGENET1K_V2")
512-
model = torch.hub.load("pytorch/vision", "resnet50", weights=weights)
513-
514-
The only exception to the above are the detection models included on
515-
:mod:`torchvision.models.detection`. These models require TorchVision
516-
to be installed because they depend on custom C++ operators.

0 commit comments

Comments
 (0)