You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* wip
* update twostage detector support
* fix unit test
* sdk wip
* comment
* refactor export info
* fix
* support roi trans
* update rotate.yml
* clear model.py, support torch1.13
- Adding `$(pwd)/build/lib` to `PYTHONPATH` is for importing mmdeploy SDK python module - `mmdeploy_python`, which will be presented in chapter [SDK model inference](#sdk-model-inference).
48
+
- When [inference onnx model by ONNX Runtime](#backend-model-inference), it requests ONNX Runtime library be found. Thus, we add it to `LD_LIBRARY_PATH`.
49
+
50
+
**Method III:** Build from source
51
+
52
+
If neither **I** nor **II** meets your requirements, [building mmdeploy from source](../01-how-to-build/build_from_source.md) is the last option.
53
+
23
54
## Convert model
24
55
56
+
You can use [tools/deploy.py](https://github.com/open-mmlab/mmdeploy/blob/dev-1.x/tools/deploy.py) to convert mmrotate models to the specified backend models. Its detailed usage can be learned from [here](https://github.com/open-mmlab/mmdeploy/blob/master/docs/en/02-how-to-run/convert_model.md#usage).
57
+
58
+
The command below shows an example about converting `rotated-faster-rcnn` model to onnx model that can be inferred by ONNX Runtime.
59
+
60
+
```shell
61
+
cd mmdeploy
62
+
63
+
# download rotated-faster-rcnn model from mmrotate model zoo
It is crucial to specify the correct deployment config during model conversion. We've already provided builtin deployment config [files](https://github.com/open-mmlab/mmdeploy/tree/dev-1.x/configs/mmrotate) of all supported backends for mmrotate. The config filename pattern is:
-**{backend}:** inference backend, such as onnxruntime, tensorrt, pplnn, ncnn, openvino, coreml etc.
86
+
-**{precision}:** fp16, int8. When it's empty, it means fp32
87
+
-**{static | dynamic}:** static shape or dynamic shape
88
+
-**{shape}:** input shape or shape range of a model
89
+
90
+
Therefore, in the above example, you can also convert `rotated-faster-rcnn` to other backend models by changing the deployment config file `rotated-detection_onnxruntime_dynamic` to [others](https://github.com/open-mmlab/mmdeploy/tree/dev-1.x/configs/mmrotate), e.g., converting to tensorrt-fp16 model by `rotated-detection_tensorrt-fp16_dynamic-320x320-1024x1024.py`.
91
+
92
+
```{tip}
93
+
When converting mmrotate models to tensorrt models, --device should be set to "cuda"
94
+
```
95
+
25
96
## Model specification
26
97
98
+
Before moving on to model inference chapter, let's know more about the converted model structure which is very important for model inference.
99
+
100
+
The converted model locates in the working directory like `mmdeploy_models/mmrotate/ort` in the previous example. It includes:
101
+
102
+
```
103
+
mmdeploy_models/mmrotate/ort
104
+
├── deploy.json
105
+
├── detail.json
106
+
├── end2end.onnx
107
+
└── pipeline.json
108
+
```
109
+
110
+
in which,
111
+
112
+
-**end2end.onnx**: backend model which can be inferred by ONNX Runtime
113
+
-\***.json**: the necessary information for mmdeploy SDK
114
+
115
+
The whole package **mmdeploy_models/mmrotate/ort** is defined as **mmdeploy SDK model**, i.e., **mmdeploy SDK model** includes both backend model and inference meta information.
116
+
27
117
## Model inference
28
118
29
119
### Backend model inference
30
120
121
+
Take the previous converted `end2end.onnx` model as an example, you can use the following code to inference the model and visualize the results.
122
+
123
+
```python
124
+
from mmdeploy.apis.utils import build_task_processor
125
+
from mmdeploy.utils import get_input_shape, load_config
Besides python API, mmdeploy SDK also provides other FFI (Foreign Function Interface), such as C, C++, C#, Java and so on. You can learn their usage from [demos](https://github.com/open-mmlab/mmdeploy/tree/dev-1.x/demo).
0 commit comments