mirror of
https://github.com/ultralytics/yolov5.git
synced 2025-06-03 14:49:29 +08:00
Update README.md
This commit is contained in:
parent
1479737064
commit
e5d71223b8
@ -121,19 +121,18 @@ Done. (0.103s)
|
|||||||
|
|
||||||
### PyTorch Hub
|
### PyTorch Hub
|
||||||
|
|
||||||
To run **batched inference** with YOLOv5 and [PyTorch Hub](https://github.com/ultralytics/yolov5/issues/36):
|
Inference with YOLOv5 and [PyTorch Hub](https://github.com/ultralytics/yolov5/issues/36):
|
||||||
```python
|
```python
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
# Model
|
# Model
|
||||||
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
|
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
|
||||||
|
|
||||||
# Images
|
# Image
|
||||||
dir = 'https://github.com/ultralytics/yolov5/raw/master/data/images/'
|
img = 'https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg'
|
||||||
imgs = [dir + f for f in ('zidane.jpg', 'bus.jpg')] # batch of images
|
|
||||||
|
|
||||||
# Inference
|
# Inference
|
||||||
results = model(imgs)
|
results = model(img)
|
||||||
results.print() # or .show(), .save()
|
results.print() # or .show(), .save()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user