Update tools/demo.py
Browse files- tools/demo.py +6 -1
tools/demo.py
CHANGED
|
@@ -4,6 +4,7 @@ import argparse
|
|
| 4 |
import os.path as osp
|
| 5 |
from functools import partial
|
| 6 |
from io import BytesIO
|
|
|
|
| 7 |
|
| 8 |
import onnx
|
| 9 |
import onnxsim
|
|
@@ -101,7 +102,7 @@ def export_model(runner,
|
|
| 101 |
iou_threshold=nms_thr,
|
| 102 |
score_threshold=score_thr)
|
| 103 |
|
| 104 |
-
base_model = runner.model
|
| 105 |
texts = [[t.strip() for t in text.split(',')] + [' ']]
|
| 106 |
base_model.reparameterize(texts)
|
| 107 |
deploy_model = DeployModel(
|
|
@@ -133,6 +134,10 @@ def export_model(runner,
|
|
| 133 |
onnx.checker.check_model(onnx_model)
|
| 134 |
onnx_model, check = onnxsim.simplify(onnx_model)
|
| 135 |
onnx.save(onnx_model, save_onnx_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
return gr.update(visible=True), save_onnx_path
|
| 137 |
|
| 138 |
|
|
|
|
| 4 |
import os.path as osp
|
| 5 |
from functools import partial
|
| 6 |
from io import BytesIO
|
| 7 |
+
from copy import deepcopy
|
| 8 |
|
| 9 |
import onnx
|
| 10 |
import onnxsim
|
|
|
|
| 102 |
iou_threshold=nms_thr,
|
| 103 |
score_threshold=score_thr)
|
| 104 |
|
| 105 |
+
base_model = deepcopy(runner.model)
|
| 106 |
texts = [[t.strip() for t in text.split(',')] + [' ']]
|
| 107 |
base_model.reparameterize(texts)
|
| 108 |
deploy_model = DeployModel(
|
|
|
|
| 134 |
onnx.checker.check_model(onnx_model)
|
| 135 |
onnx_model, check = onnxsim.simplify(onnx_model)
|
| 136 |
onnx.save(onnx_model, save_onnx_path)
|
| 137 |
+
|
| 138 |
+
del base_model
|
| 139 |
+
del deploy_model
|
| 140 |
+
del onnx_model
|
| 141 |
return gr.update(visible=True), save_onnx_path
|
| 142 |
|
| 143 |
|