Skip to content

Commit 11b4479

Browse files
authored
Update README.zh-cn.md
1 parent e3c0d65 commit 11b4479

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.zh-cn.md

+32
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,38 @@ trt_model = tp.from_torch(model, input)
4040
trt_out = trt_model(input)
4141
```
4242

43+
- 简单的yolo python接口
44+
- 要求: nvidia驱动 >= 440.33, 操作系统linux x86_64, python37/python38/python39
45+
- `pip install trtpy`, 这是一个实验包,您可以通过pip进行安装,目前提供了yolo支持,删除了repo中的其他项,在不久的将来会提供更新
46+
- 通过这个指令安装,您就可以使用python接口,而不需要配置cuda、cudnn、tensorRT等系列
47+
- 内置的版本:CUDA10.2、CUDNN8.2.2.26、TensorRT8.0.1.6、protobuf3.11.4
48+
```python
49+
import os
50+
import cv2
51+
import numpy as np
52+
import trtpy as tp
53+
54+
engine_file = "yolov5s.fp32.trtmodel"
55+
if not os.path.exists(engine_file):
56+
tp.compile_onnx_to_file(1, tp.onnx_hub("yolov5s"), engine_file)
57+
58+
yolo = tp.Yolo(engine_file, type=tp.YoloType.V5)
59+
image = cv2.imread("car.jpg")
60+
bboxes = yolo.commit(image).get()
61+
print(f"{len(bboxes)} objects")
62+
63+
for box in bboxes:
64+
left, top, right, bottom = map(int, [box.left, box.top, box.right, box.bottom])
65+
cv2.rectangle(image, (left, top), (right, bottom), tp.random_color(box.class_label), 5)
66+
67+
saveto = "yolov5.car.jpg"
68+
print(f"Save to {saveto}")
69+
70+
cv2.imwrite(saveto, image)
71+
cv2.imshow("result", image)
72+
cv2.waitKey()
73+
```
74+
4375

4476
## 简介
4577
1. 基于tensorRT8.0,C++/Python高级接口

0 commit comments

Comments
 (0)