|
@@ -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)
|