-
Notifications
You must be signed in to change notification settings - Fork 53
/
ldfnet.patch
36 lines (36 loc) · 1.17 KB
/
ldfnet.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
32
33
34
35
36
diff -x .git -x .gitignore -r -N -r -u ./model/to_onnx.py esanet/src/models/external_code/LDFNet/model/to_onnx.py
--- ./model/to_onnx.py 1970-01-01 01:00:00.000000000 +0100
+++ esanet/src/models/external_code/LDFNet/model/to_onnx.py 2020-12-04 17:56:52.000000000 +0100
@@ -0,0 +1,31 @@
+from torch import nn
+import os
+import torch
+
+from LDFNet import Net
+
+H = 512
+W = 1024
+N_CLASSES = 19
+
+criterion = nn.CrossEntropyLoss(reduction='mean', ignore_index=255)
+model = Net(N_CLASSES)
+model.eval()
+
+rgb = torch.rand(size=(1, 3, H, W), dtype=torch.float32)
+depth_luminance = torch.rand(size=(1, 2, H, W), dtype=torch.float32)
+
+out_dir = '../../onnx_models'
+os.makedirs(out_dir, exist_ok=True)
+onnx_file_path = os.path.join(out_dir, 'ldfnet.onnx')
+torch.onnx.export(model,
+ (rgb, depth_luminance),
+ onnx_file_path,
+ export_params=True,
+ input_names=['rgb', 'hha'],
+ output_names=['output'],
+ do_constant_folding=True,
+ verbose=False,
+ opset_version=10
+ )
+print(f'exported {onnx_file_path}')
\ No newline at end of file