Update Python example
parent
353b892c45
commit
480a53c640
16
README.md
16
README.md
|
@ -77,7 +77,7 @@ pip install -r requirements.txt # install
|
|||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<details open>
|
||||
<summary>Inference</summary>
|
||||
|
||||
YOLOv5 [PyTorch Hub](https://docs.ultralytics.com/yolov5/tutorials/pytorch_hub_model_loading/) inference. [Models](https://github.com/ultralytics/yolov5/tree/master/models) download automatically from the latest YOLOv5 [release](https://github.com/ultralytics/yolov5/releases).
|
||||
|
@ -85,17 +85,17 @@ YOLOv5 [PyTorch Hub](https://docs.ultralytics.com/yolov5/tutorials/pytorch_hub_m
|
|||
```python
|
||||
import torch
|
||||
|
||||
# Model
|
||||
model = torch.hub.load("ultralytics/yolov5", "yolov5s") # or yolov5n - yolov5x6, custom
|
||||
# Load YOLOv5 model (options: yolov5n, yolov5s, yolov5m, yolov5l, yolov5x)
|
||||
model = torch.hub.load("ultralytics/yolov5", "yolov5s")
|
||||
|
||||
# Images
|
||||
img = "https://ultralytics.com/images/zidane.jpg" # or file, Path, PIL, OpenCV, numpy, list
|
||||
# Input source (URL, file, PIL, OpenCV, numpy array, or list)
|
||||
img = "https://ultralytics.com/images/zidane.jpg"
|
||||
|
||||
# Inference
|
||||
# Perform inference (handles batching, resizing, normalization)
|
||||
results = model(img)
|
||||
|
||||
# Results
|
||||
results.print() # or .show(), .save(), .crop(), .pandas(), etc.
|
||||
# Process results (options: .print(), .show(), .save(), .crop(), .pandas())
|
||||
results.print()
|
||||
```
|
||||
|
||||
</details>
|
||||
|
|
|
@ -73,7 +73,7 @@ cd yolov5
|
|||
pip install -r requirements.txt # install
|
||||
```
|
||||
|
||||
</details>
|
||||
</details open>
|
||||
|
||||
<details>
|
||||
<summary>推理</summary>
|
||||
|
@ -83,17 +83,17 @@ pip install -r requirements.txt # install
|
|||
```python
|
||||
import torch
|
||||
|
||||
# Model
|
||||
model = torch.hub.load("ultralytics/yolov5", "yolov5s") # or yolov5n - yolov5x6, custom
|
||||
# 加载 YOLOv5 模型 (选项: yolov5n, yolov5s, yolov5m, yolov5l, yolov5x)
|
||||
model = torch.hub.load("ultralytics/yolov5", "yolov5s")
|
||||
|
||||
# Images
|
||||
img = "https://ultralytics.com/images/zidane.jpg" # or file, Path, PIL, OpenCV, numpy, list
|
||||
# 输入源 (URL, 文件, PIL, OpenCV, numpy 数组, 或列表)
|
||||
img = "https://ultralytics.com/images/zidane.jpg"
|
||||
|
||||
# Inference
|
||||
# 执行推理 (自动处理批处理, 调整大小, 标准化)
|
||||
results = model(img)
|
||||
|
||||
# Results
|
||||
results.print() # or .show(), .save(), .crop(), .pandas(), etc.
|
||||
# 处理结果 (选项: .print(), .show(), .save(), .crop(), .pandas())
|
||||
results.print()
|
||||
```
|
||||
|
||||
</details>
|
||||
|
|
Loading…
Reference in New Issue