lissank commited on
Commit
9aeaeb8
1 Parent(s): e9a7cf7

Update tools/demo.py

Browse files
Files changed (1) hide show
  1. 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
- save_onnx_path = os.path.join(
130
- 'work_dirs', 'yolow-l.onnx')
131
- # export onnx
132
- with BytesIO() as f:
133
- output_names = ['num_dets', 'boxes', 'scores', 'labels']
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
- del onnx_model
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):