Browse Source

更新Readme

leon 5 months ago
parent
commit
d8a97f2344
1 changed files with 22 additions and 1 deletions
  1. 22 1
      README.md

+ 22 - 1
README.md

@@ -37,7 +37,28 @@ trtexec --onnx=resnet.onnx --saveEngine=resnet.engine --fp16 --verbose
 | 模型 | 精度 | 时间 |
 | --- | --- | ---|
 | resnet34 | fp16 | 0.49488ms |
-   
+
+
+#### python推理
+说明:使用了pybind11,将C++代码编译成so,可以让python直接import调用
+```python
+from workspace import trtresnet
+import cv2
+
+infer = trtresnet.TrtResnetInfer("workspace/resnet.engine")
+
+# image = cv2.imread("workspace/inference/car.jpg")
+result = infer.forward_path("workspace/inference/car.jpg")
+
+
+print(result)
+
+image = cv2.imread("workspace/inference/car.jpg")
+
+result = infer.forward(image)
+
+print(result)
+```
 
 ## Reference
 - [🌻shouxieai/infer](https://github.com/shouxieai/infer)