Spaces:
Sleeping
Sleeping
Update tools/demo.py
Browse files- tools/demo.py +6 -19
tools/demo.py
CHANGED
@@ -126,28 +126,15 @@ def export_model(runner,
|
|
126 |
deploy_model(fake_input)
|
127 |
|
128 |
os.makedirs('work_dirs', exist_ok=True)
|
129 |
-
|
130 |
-
'work_dirs', 'yolow-l.
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
torch.onnx.export(
|
135 |
-
deploy_model,
|
136 |
-
fake_input,
|
137 |
-
f,
|
138 |
-
input_names=['images'],
|
139 |
-
output_names=output_names,
|
140 |
-
opset_version=12)
|
141 |
-
f.seek(0)
|
142 |
-
onnx_model = onnx.load(f)
|
143 |
-
onnx.checker.check_model(onnx_model)
|
144 |
-
onnx_model, check = onnxsim.simplify(onnx_model)
|
145 |
-
onnx.save(onnx_model, save_onnx_path)
|
146 |
|
147 |
del base_model
|
148 |
del deploy_model
|
149 |
-
|
150 |
-
return gr.update(visible=True), save_onnx_path
|
151 |
|
152 |
|
153 |
def demo(runner, args, cfg):
|
|
|
126 |
deploy_model(fake_input)
|
127 |
|
128 |
os.makedirs('work_dirs', exist_ok=True)
|
129 |
+
save_pt_path = os.path.join(
|
130 |
+
'work_dirs', 'yolow-l.pt')
|
131 |
+
|
132 |
+
# Save model as a .pt file
|
133 |
+
torch.save(deploy_model.state_dict(), save_pt_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
del base_model
|
136 |
del deploy_model
|
137 |
+
return gr.update(visible=True), save_pt_path
|
|
|
138 |
|
139 |
|
140 |
def demo(runner, args, cfg):
|