Skip to content

Commit 676c17d

Browse files
committed
added sample code for fasterrcnn_resnet50_fpn (optional)
1 parent 6044386 commit 676c17d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

intermediate_source/torchvision_tutorial.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ Before iterating over the dataset, it's always good to see what the model
311311
expects during training and inference time with random tensors.
312312

313313
.. code:: python
314+
314315
model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True)
315316
images,boxes,labels = torch.rand(4,3,600,1200), torch.rand(4,11,4), torch.rand(4,11) # For Training
316317
images = list(image for image in images) # This is handled by GeneralizedRCNNTransform
@@ -320,11 +321,11 @@ expects during training and inference time with random tensors.
320321
d['boxes'] = boxes[i]
321322
d['labels'] = labels[i].type(torch.int64)
322323
targets.append(d)
323-
output = model(images,targets)
324+
output = model(images,targets) # Returns losses and detections
324325
325326
model.eval() # For inference
326327
x = [torch.rand(3, 300, 400), torch.rand(3, 500, 400)]
327-
predictions = model(x)
328+
predictions = model(x) # Returns predictions
328329
329330
330331
Putting everything together

0 commit comments

Comments
 (0)