-
Notifications
You must be signed in to change notification settings - Fork 53
/
erfnet.patch
31 lines (31 loc) · 999 Bytes
/
erfnet.patch
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
diff -x .git -x .gitignore -x '*.pth*' -x example_segmentation.png -r -N -r -u ./train/to_onnx.py esanet/src/models/external_code/erfnet_pytorch/train/to_onnx.py
--- ./train/to_onnx.py 1970-01-01 01:00:00.000000000 +0100
+++ esanet/src/models/external_code/erfnet_pytorch/train/to_onnx.py 2020-12-04 17:56:52.000000000 +0100
@@ -0,0 +1,27 @@
+import os
+import torch
+from erfnet import Net
+
+N_CLASSES = 19
+H = 512
+W = 1024
+
+model = Net(N_CLASSES)
+model.eval()
+
+rgb = torch.rand(size=(1, 3, H, W), dtype=torch.float32)
+
+out_dir = '../../onnx_models'
+os.makedirs(out_dir, exist_ok=True)
+onnx_file_path = os.path.join(out_dir, 'erfnet.onnx')
+
+torch.onnx.export(model,
+ rgb,
+ onnx_file_path,
+ export_params=True,
+ input_names=['rgb'],
+ output_names=['output'],
+ do_constant_folding=True,
+ verbose=False,
+ opset_version=11
+ )