forked from PanJinquan/DL-Converter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
onnx2tnn_v1.sh
executable file
·43 lines (36 loc) · 1.14 KB
/
onnx2tnn_v1.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
# step
# docker run --rm --volume=$(pwd):/opt/TNN/tools/onnx2tnn/onnx-converter/workspace -it tnn-convert:latest /bin/bash
# cd /opt/TNN/tools/onnx2tnn/onnx-converter
# bash workspace/utils/onnx2tnn.sh
model_name="rfb1.0_face_320_320_freeze_header"
#model_name="best_model_164_0.9478"
onnx_path="workspace/data/pretrained/onnx/"$model_name".onnx"
sim_onnx_path="workspace/data/pretrained/onnx/"$model_name"_sim.onnx"
tnn_model="workspace/data/pretrained/tnn/"
# https://github.com/daquexian/onnx-simplifier
# pip3 install onnx-simplifier
# pip install --upgrade onnx
# python -m onnxsim path/to/src.onnx path/to/src_sim.onnx 0(不做check) --input-shape 1,112,112,3
python3 -m onnxsim \
$onnx_path \
$sim_onnx_path \
0 \
--input-shape 1,3,320,320
#
#onnx_path=$sim_onnx_path
# https://github.com/Tencent/TNN/blob/master/doc/cn/user/onnx2tnn.md
#python3 converter.py onnx2tnn \
# $onnx_path \
# -optimize \
# -v=v3.0 \
# -o $tnn_model \
# -align \
# -input_file in.txt \
# -ref_file ref.txt
python3 onnx2tnn.py \
$onnx_path \
-version=v3.0 \
-optimize=1 \
-half=0 \
-o $tnn_model \