MRiabov commited on
Commit
8223f36
·
1 Parent(s): 2991754

(minor refactor) os.path to pathlib and tdqm to infer.py

Browse files
.gitignore CHANGED
@@ -123,3 +123,10 @@ dataset/
123
 
124
  #runs
125
  runs/
 
 
 
 
 
 
 
 
123
 
124
  #runs
125
  runs/
126
+ *.pt
127
+
128
+ #exports
129
+ exports/
130
+ *.onnx
131
+ *.trt
132
+ *.nnx
infer.py CHANGED
@@ -10,8 +10,10 @@ import cv2
10
  import torch
11
  import torch.nn.functional as F
12
  from torch.amp import autocast
 
13
 
14
  from src.wireseghr.model import WireSegHR
 
15
 
16
 
17
  def _pad_for_minmax(kernel: int) -> Tuple[int, int, int, int]:
@@ -179,7 +181,7 @@ def infer_image(
179
  save_prob: bool = False,
180
  prob_thresh: Optional[float] = None,
181
  ) -> Tuple[np.ndarray, np.ndarray]:
182
- assert os.path.isfile(img_path), f"Image not found: {img_path}"
183
  bgr = cv2.imread(img_path, cv2.IMREAD_COLOR)
184
  assert bgr is not None, f"Failed to read {img_path}"
185
  rgb = cv2.cvtColor(bgr, cv2.COLOR_BGR2RGB).astype(np.float32) / 255.0
@@ -223,11 +225,11 @@ def infer_image(
223
 
224
  if out_dir is not None:
225
  os.makedirs(out_dir, exist_ok=True)
226
- stem = os.path.splitext(os.path.basename(img_path))[0]
227
- out_mask = os.path.join(out_dir, f"{stem}_pred.png")
228
- cv2.imwrite(out_mask, pred)
229
  if save_prob:
230
- out_prob = os.path.join(out_dir, f"{stem}_prob.npy")
231
  np.save(out_prob, prob_f.detach().cpu().float().numpy())
232
 
233
  # Return numpy arrays for external consumers, computed via torch
@@ -298,8 +300,8 @@ def main():
298
  args = parser.parse_args()
299
 
300
  cfg_path = args.config
301
- if not os.path.isabs(cfg_path):
302
- cfg_path = os.path.join(os.getcwd(), cfg_path)
303
 
304
  with open(cfg_path, "r") as f:
305
  cfg = yaml.safe_load(f)
@@ -327,7 +329,7 @@ def main():
327
 
328
  ckpt_path = args.ckpt if args.ckpt else cfg.get("resume", "")
329
  if ckpt_path:
330
- assert os.path.isfile(ckpt_path), f"Checkpoint not found: {ckpt_path}"
331
  print(f"[WireSegHR][infer] Loading checkpoint: {ckpt_path}")
332
  state = torch.load(ckpt_path, map_location=device)
333
  model.load_state_dict(state["model"])
@@ -339,7 +341,7 @@ def main():
339
  bench_dir = args.bench_images_dir
340
  else:
341
  bench_dir = cfg["data"]["test_images"]
342
- assert os.path.isdir(bench_dir), f"Not a directory: {bench_dir}"
343
 
344
  size_filter: Optional[Tuple[int, int]] = None
345
  if args.bench_size_filter:
@@ -353,7 +355,7 @@ def main():
353
 
354
  img_files = sorted(
355
  [
356
- os.path.join(bench_dir, p)
357
  for p in os.listdir(bench_dir)
358
  if p.lower().endswith((".jpg", ".jpeg"))
359
  ]
@@ -386,7 +388,7 @@ def main():
386
  timings: List[Dict[str, Any]] = []
387
 
388
  # Warmup
389
- for i in range(min(args.bench_warmup, len(img_files))):
390
  _ = infer_image(
391
  model,
392
  img_files[i],
@@ -399,7 +401,7 @@ def main():
399
  )
400
 
401
  # Timed runs
402
- for p in img_files[args.bench_warmup :]:
403
  # Replicate internals to time coarse vs fine separately
404
  bgr = cv2.imread(p, cv2.IMREAD_COLOR)
405
  assert bgr is not None, f"Failed to read {p}"
@@ -487,7 +489,9 @@ def main():
487
  },
488
  "per_image": timings,
489
  }
490
- with open(args.bench_report_json, "w") as f:
 
 
491
  json.dump(report, f, indent=2)
492
 
493
  return
@@ -508,14 +512,14 @@ def main():
508
 
509
  # Directory mode
510
  img_dir = args.images_dir
511
- assert os.path.isdir(img_dir), f"Not a directory: {img_dir}"
512
  img_files = sorted(
513
  [p for p in os.listdir(img_dir) if p.lower().endswith((".jpg", ".jpeg"))]
514
  )
515
  assert len(img_files) > 0, f"No .jpg/.jpeg in {img_dir}"
516
  os.makedirs(args.out, exist_ok=True)
517
- for name in img_files:
518
- path = os.path.join(img_dir, name)
519
  infer_image(
520
  model,
521
  path,
 
10
  import torch
11
  import torch.nn.functional as F
12
  from torch.amp import autocast
13
+ from tqdm import tqdm
14
 
15
  from src.wireseghr.model import WireSegHR
16
+ from pathlib import Path
17
 
18
 
19
  def _pad_for_minmax(kernel: int) -> Tuple[int, int, int, int]:
 
181
  save_prob: bool = False,
182
  prob_thresh: Optional[float] = None,
183
  ) -> Tuple[np.ndarray, np.ndarray]:
184
+ assert Path(img_path).is_file(), f"Image not found: {img_path}"
185
  bgr = cv2.imread(img_path, cv2.IMREAD_COLOR)
186
  assert bgr is not None, f"Failed to read {img_path}"
187
  rgb = cv2.cvtColor(bgr, cv2.COLOR_BGR2RGB).astype(np.float32) / 255.0
 
225
 
226
  if out_dir is not None:
227
  os.makedirs(out_dir, exist_ok=True)
228
+ stem = Path(img_path).stem
229
+ out_mask = Path(out_dir) / f"{stem}_pred.png"
230
+ cv2.imwrite(str(out_mask), pred)
231
  if save_prob:
232
+ out_prob = Path(out_dir) / f"{stem}_prob.npy"
233
  np.save(out_prob, prob_f.detach().cpu().float().numpy())
234
 
235
  # Return numpy arrays for external consumers, computed via torch
 
300
  args = parser.parse_args()
301
 
302
  cfg_path = args.config
303
+ if not Path(cfg_path).is_absolute():
304
+ cfg_path = str(Path.cwd() / cfg_path)
305
 
306
  with open(cfg_path, "r") as f:
307
  cfg = yaml.safe_load(f)
 
329
 
330
  ckpt_path = args.ckpt if args.ckpt else cfg.get("resume", "")
331
  if ckpt_path:
332
+ assert Path(ckpt_path).is_file(), f"Checkpoint not found: {ckpt_path}"
333
  print(f"[WireSegHR][infer] Loading checkpoint: {ckpt_path}")
334
  state = torch.load(ckpt_path, map_location=device)
335
  model.load_state_dict(state["model"])
 
341
  bench_dir = args.bench_images_dir
342
  else:
343
  bench_dir = cfg["data"]["test_images"]
344
+ assert Path(bench_dir).is_dir(), f"Not a directory: {bench_dir}"
345
 
346
  size_filter: Optional[Tuple[int, int]] = None
347
  if args.bench_size_filter:
 
355
 
356
  img_files = sorted(
357
  [
358
+ str(Path(bench_dir) / p)
359
  for p in os.listdir(bench_dir)
360
  if p.lower().endswith((".jpg", ".jpeg"))
361
  ]
 
388
  timings: List[Dict[str, Any]] = []
389
 
390
  # Warmup
391
+ for i in tqdm(range(min(args.bench_warmup, len(img_files))), desc="[bench] Warmup"):
392
  _ = infer_image(
393
  model,
394
  img_files[i],
 
401
  )
402
 
403
  # Timed runs
404
+ for p in tqdm(img_files[args.bench_warmup :], desc="[bench] Timed"):
405
  # Replicate internals to time coarse vs fine separately
406
  bgr = cv2.imread(p, cv2.IMREAD_COLOR)
407
  assert bgr is not None, f"Failed to read {p}"
 
489
  },
490
  "per_image": timings,
491
  }
492
+ report_path = args.bench_report_json
493
+ Path(report_path).parent.mkdir(parents=True, exist_ok=True)
494
+ with open(report_path, "w") as f:
495
  json.dump(report, f, indent=2)
496
 
497
  return
 
512
 
513
  # Directory mode
514
  img_dir = args.images_dir
515
+ assert Path(img_dir).is_dir(), f"Not a directory: {img_dir}"
516
  img_files = sorted(
517
  [p for p in os.listdir(img_dir) if p.lower().endswith((".jpg", ".jpeg"))]
518
  )
519
  assert len(img_files) > 0, f"No .jpg/.jpeg in {img_dir}"
520
  os.makedirs(args.out, exist_ok=True)
521
+ for name in tqdm(img_files, desc="[infer] Dir"):
522
+ path = str(Path(img_dir) / name)
523
  infer_image(
524
  model,
525
  path,
outputs/bench_report.json ADDED
@@ -0,0 +1,1332 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "summary": {
3
+ "avg_ms": 546.1088118905371,
4
+ "p50_ms": 472.0355123281479,
5
+ "p95_ms": 1127.635708078742,
6
+ "avg_coarse_ms": 50.732872945566974,
7
+ "avg_fine_ms": 495.37593894497013,
8
+ "images": 165
9
+ },
10
+ "per_image": [
11
+ {
12
+ "path": "dataset/test/images/1035.jpg",
13
+ "H": 2160,
14
+ "W": 3840,
15
+ "t_coarse_ms": 45.59382610023022,
16
+ "t_fine_ms": 439.33012057095766,
17
+ "t_total_ms": 484.9239466711879
18
+ },
19
+ {
20
+ "path": "dataset/test/images/1044.jpg",
21
+ "H": 2160,
22
+ "W": 3840,
23
+ "t_coarse_ms": 45.9147822111845,
24
+ "t_fine_ms": 424.12184551358223,
25
+ "t_total_ms": 470.03662772476673
26
+ },
27
+ {
28
+ "path": "dataset/test/images/1084.jpg",
29
+ "H": 2160,
30
+ "W": 3840,
31
+ "t_coarse_ms": 49.31220877915621,
32
+ "t_fine_ms": 439.04411140829325,
33
+ "t_total_ms": 488.35632018744946
34
+ },
35
+ {
36
+ "path": "dataset/test/images/1094.jpg",
37
+ "H": 2160,
38
+ "W": 3840,
39
+ "t_coarse_ms": 43.984285555779934,
40
+ "t_fine_ms": 424.1811977699399,
41
+ "t_total_ms": 468.16548332571983
42
+ },
43
+ {
44
+ "path": "dataset/test/images/1099.jpg",
45
+ "H": 2160,
46
+ "W": 3840,
47
+ "t_coarse_ms": 44.372158125042915,
48
+ "t_fine_ms": 424.29234832525253,
49
+ "t_total_ms": 468.66450645029545
50
+ },
51
+ {
52
+ "path": "dataset/test/images/1100.jpg",
53
+ "H": 2160,
54
+ "W": 3840,
55
+ "t_coarse_ms": 44.085255824029446,
56
+ "t_fine_ms": 424.2294393479824,
57
+ "t_total_ms": 468.31469517201185
58
+ },
59
+ {
60
+ "path": "dataset/test/images/1104.jpg",
61
+ "H": 2160,
62
+ "W": 3840,
63
+ "t_coarse_ms": 44.348194263875484,
64
+ "t_fine_ms": 424.35442470014095,
65
+ "t_total_ms": 468.70261896401644
66
+ },
67
+ {
68
+ "path": "dataset/test/images/1117.jpg",
69
+ "H": 2160,
70
+ "W": 3840,
71
+ "t_coarse_ms": 44.24700140953064,
72
+ "t_fine_ms": 424.39749650657177,
73
+ "t_total_ms": 468.6444979161024
74
+ },
75
+ {
76
+ "path": "dataset/test/images/1131.jpg",
77
+ "H": 2160,
78
+ "W": 3840,
79
+ "t_coarse_ms": 46.00091464817524,
80
+ "t_fine_ms": 439.06145449727774,
81
+ "t_total_ms": 485.062369145453
82
+ },
83
+ {
84
+ "path": "dataset/test/images/1134.jpg",
85
+ "H": 2160,
86
+ "W": 3840,
87
+ "t_coarse_ms": 44.08291168510914,
88
+ "t_fine_ms": 424.22800697386265,
89
+ "t_total_ms": 468.3109186589718
90
+ },
91
+ {
92
+ "path": "dataset/test/images/1141.jpg",
93
+ "H": 2160,
94
+ "W": 3840,
95
+ "t_coarse_ms": 44.215052388608456,
96
+ "t_fine_ms": 436.8190476670861,
97
+ "t_total_ms": 481.0341000556946
98
+ },
99
+ {
100
+ "path": "dataset/test/images/115.jpg",
101
+ "H": 3024,
102
+ "W": 4032,
103
+ "t_coarse_ms": 48.61736670136452,
104
+ "t_fine_ms": 571.8103954568505,
105
+ "t_total_ms": 620.427762158215
106
+ },
107
+ {
108
+ "path": "dataset/test/images/1150.jpg",
109
+ "H": 2160,
110
+ "W": 3840,
111
+ "t_coarse_ms": 44.28734816610813,
112
+ "t_fine_ms": 424.50483050197363,
113
+ "t_total_ms": 468.79217866808176
114
+ },
115
+ {
116
+ "path": "dataset/test/images/1162.jpg",
117
+ "H": 2160,
118
+ "W": 3840,
119
+ "t_coarse_ms": 44.25444547086954,
120
+ "t_fine_ms": 424.3017351254821,
121
+ "t_total_ms": 468.5561805963516
122
+ },
123
+ {
124
+ "path": "dataset/test/images/1183.jpg",
125
+ "H": 2160,
126
+ "W": 3840,
127
+ "t_coarse_ms": 50.017811357975006,
128
+ "t_fine_ms": 424.20240864157677,
129
+ "t_total_ms": 474.2202199995518
130
+ },
131
+ {
132
+ "path": "dataset/test/images/1196.jpg",
133
+ "H": 2160,
134
+ "W": 3840,
135
+ "t_coarse_ms": 44.7112787514925,
136
+ "t_fine_ms": 424.5493831112981,
137
+ "t_total_ms": 469.2606618627906
138
+ },
139
+ {
140
+ "path": "dataset/test/images/1198.jpg",
141
+ "H": 2160,
142
+ "W": 3840,
143
+ "t_coarse_ms": 46.2280735373497,
144
+ "t_fine_ms": 424.4956923648715,
145
+ "t_total_ms": 470.7237659022212
146
+ },
147
+ {
148
+ "path": "dataset/test/images/1207.jpg",
149
+ "H": 2160,
150
+ "W": 3840,
151
+ "t_coarse_ms": 44.30075362324715,
152
+ "t_fine_ms": 425.1869274303317,
153
+ "t_total_ms": 469.48768105357885
154
+ },
155
+ {
156
+ "path": "dataset/test/images/1210.jpg",
157
+ "H": 2160,
158
+ "W": 3840,
159
+ "t_coarse_ms": 44.36945356428623,
160
+ "t_fine_ms": 424.6001597493887,
161
+ "t_total_ms": 468.9696133136749
162
+ },
163
+ {
164
+ "path": "dataset/test/images/1221.jpg",
165
+ "H": 2160,
166
+ "W": 3840,
167
+ "t_coarse_ms": 44.113208539783955,
168
+ "t_fine_ms": 424.9595580622554,
169
+ "t_total_ms": 469.07276660203934
170
+ },
171
+ {
172
+ "path": "dataset/test/images/1222.jpg",
173
+ "H": 2160,
174
+ "W": 3840,
175
+ "t_coarse_ms": 46.22312355786562,
176
+ "t_fine_ms": 424.90849178284407,
177
+ "t_total_ms": 471.1316153407097
178
+ },
179
+ {
180
+ "path": "dataset/test/images/1233.jpg",
181
+ "H": 2160,
182
+ "W": 3840,
183
+ "t_coarse_ms": 44.367230497300625,
184
+ "t_fine_ms": 429.00559958070517,
185
+ "t_total_ms": 473.3728300780058
186
+ },
187
+ {
188
+ "path": "dataset/test/images/1237.jpg",
189
+ "H": 2160,
190
+ "W": 3840,
191
+ "t_coarse_ms": 46.076808124780655,
192
+ "t_fine_ms": 424.8273679986596,
193
+ "t_total_ms": 470.90417612344027
194
+ },
195
+ {
196
+ "path": "dataset/test/images/1248.jpg",
197
+ "H": 2160,
198
+ "W": 3840,
199
+ "t_coarse_ms": 44.484411366283894,
200
+ "t_fine_ms": 424.7051477432251,
201
+ "t_total_ms": 469.189559109509
202
+ },
203
+ {
204
+ "path": "dataset/test/images/1267.jpg",
205
+ "H": 2160,
206
+ "W": 3840,
207
+ "t_coarse_ms": 45.97096797078848,
208
+ "t_fine_ms": 424.8329382389784,
209
+ "t_total_ms": 470.80390620976686
210
+ },
211
+ {
212
+ "path": "dataset/test/images/1286.jpg",
213
+ "H": 2160,
214
+ "W": 3840,
215
+ "t_coarse_ms": 44.26971450448036,
216
+ "t_fine_ms": 425.51194224506617,
217
+ "t_total_ms": 469.7816567495465
218
+ },
219
+ {
220
+ "path": "dataset/test/images/1288.jpg",
221
+ "H": 2160,
222
+ "W": 3840,
223
+ "t_coarse_ms": 44.41062081605196,
224
+ "t_fine_ms": 424.7751794755459,
225
+ "t_total_ms": 469.18580029159784
226
+ },
227
+ {
228
+ "path": "dataset/test/images/1301.jpg",
229
+ "H": 2160,
230
+ "W": 3840,
231
+ "t_coarse_ms": 46.415708027780056,
232
+ "t_fine_ms": 425.1723997294903,
233
+ "t_total_ms": 471.58810775727034
234
+ },
235
+ {
236
+ "path": "dataset/test/images/1302.jpg",
237
+ "H": 2160,
238
+ "W": 3840,
239
+ "t_coarse_ms": 51.42174381762743,
240
+ "t_fine_ms": 441.5710028260946,
241
+ "t_total_ms": 492.99274664372206
242
+ },
243
+ {
244
+ "path": "dataset/test/images/131.jpg",
245
+ "H": 2304,
246
+ "W": 3072,
247
+ "t_coarse_ms": 43.16047020256519,
248
+ "t_fine_ms": 342.8378105163574,
249
+ "t_total_ms": 385.9982807189226
250
+ },
251
+ {
252
+ "path": "dataset/test/images/1310.jpg",
253
+ "H": 2160,
254
+ "W": 3840,
255
+ "t_coarse_ms": 44.35443505644798,
256
+ "t_fine_ms": 434.8618807271123,
257
+ "t_total_ms": 479.2163157835603
258
+ },
259
+ {
260
+ "path": "dataset/test/images/1311.jpg",
261
+ "H": 2160,
262
+ "W": 3840,
263
+ "t_coarse_ms": 44.472177512943745,
264
+ "t_fine_ms": 425.3980163484812,
265
+ "t_total_ms": 469.8701938614249
266
+ },
267
+ {
268
+ "path": "dataset/test/images/1317.jpg",
269
+ "H": 2160,
270
+ "W": 3840,
271
+ "t_coarse_ms": 45.67752406001091,
272
+ "t_fine_ms": 425.11772736907005,
273
+ "t_total_ms": 470.79525142908096
274
+ },
275
+ {
276
+ "path": "dataset/test/images/1328.jpg",
277
+ "H": 2160,
278
+ "W": 3840,
279
+ "t_coarse_ms": 44.30837836116552,
280
+ "t_fine_ms": 425.1418113708496,
281
+ "t_total_ms": 469.45018973201513
282
+ },
283
+ {
284
+ "path": "dataset/test/images/1331.jpg",
285
+ "H": 2160,
286
+ "W": 3840,
287
+ "t_coarse_ms": 44.26242224872112,
288
+ "t_fine_ms": 425.35913176834583,
289
+ "t_total_ms": 469.62155401706696
290
+ },
291
+ {
292
+ "path": "dataset/test/images/1343.jpg",
293
+ "H": 2160,
294
+ "W": 3840,
295
+ "t_coarse_ms": 44.27749011665583,
296
+ "t_fine_ms": 425.03981012851,
297
+ "t_total_ms": 469.3173002451658
298
+ },
299
+ {
300
+ "path": "dataset/test/images/1355.jpg",
301
+ "H": 2160,
302
+ "W": 3840,
303
+ "t_coarse_ms": 44.47717685252428,
304
+ "t_fine_ms": 424.78822357952595,
305
+ "t_total_ms": 469.2654004320502
306
+ },
307
+ {
308
+ "path": "dataset/test/images/136.jpg",
309
+ "H": 4032,
310
+ "W": 3024,
311
+ "t_coarse_ms": 50.84674712270498,
312
+ "t_fine_ms": 571.7228697612882,
313
+ "t_total_ms": 622.5696168839931
314
+ },
315
+ {
316
+ "path": "dataset/test/images/1373.jpg",
317
+ "H": 2160,
318
+ "W": 3840,
319
+ "t_coarse_ms": 48.84865414351225,
320
+ "t_fine_ms": 428.99321764707565,
321
+ "t_total_ms": 477.8418717905879
322
+ },
323
+ {
324
+ "path": "dataset/test/images/1386.jpg",
325
+ "H": 2160,
326
+ "W": 3840,
327
+ "t_coarse_ms": 45.799785293638706,
328
+ "t_fine_ms": 425.5906594917178,
329
+ "t_total_ms": 471.3904447853565
330
+ },
331
+ {
332
+ "path": "dataset/test/images/1394.jpg",
333
+ "H": 2160,
334
+ "W": 3840,
335
+ "t_coarse_ms": 44.49394904077053,
336
+ "t_fine_ms": 424.9263955280185,
337
+ "t_total_ms": 469.420344568789
338
+ },
339
+ {
340
+ "path": "dataset/test/images/1397.jpg",
341
+ "H": 2160,
342
+ "W": 3840,
343
+ "t_coarse_ms": 44.70691177994013,
344
+ "t_fine_ms": 434.18938014656305,
345
+ "t_total_ms": 478.8962919265032
346
+ },
347
+ {
348
+ "path": "dataset/test/images/14.jpg",
349
+ "H": 6000,
350
+ "W": 4000,
351
+ "t_coarse_ms": 94.20748520642519,
352
+ "t_fine_ms": 1047.5239856168628,
353
+ "t_total_ms": 1141.731470823288
354
+ },
355
+ {
356
+ "path": "dataset/test/images/1400.jpg",
357
+ "H": 2160,
358
+ "W": 3840,
359
+ "t_coarse_ms": 52.839730866253376,
360
+ "t_fine_ms": 437.71414924412966,
361
+ "t_total_ms": 490.55388011038303
362
+ },
363
+ {
364
+ "path": "dataset/test/images/1403.jpg",
365
+ "H": 2160,
366
+ "W": 3840,
367
+ "t_coarse_ms": 46.125128865242004,
368
+ "t_fine_ms": 425.45598559081554,
369
+ "t_total_ms": 471.58111445605755
370
+ },
371
+ {
372
+ "path": "dataset/test/images/1410.jpg",
373
+ "H": 2160,
374
+ "W": 3840,
375
+ "t_coarse_ms": 44.58910785615444,
376
+ "t_fine_ms": 425.4433121532202,
377
+ "t_total_ms": 470.0324200093746
378
+ },
379
+ {
380
+ "path": "dataset/test/images/143.jpg",
381
+ "H": 3024,
382
+ "W": 4032,
383
+ "t_coarse_ms": 50.99013913422823,
384
+ "t_fine_ms": 576.6453053802252,
385
+ "t_total_ms": 627.6354445144534
386
+ },
387
+ {
388
+ "path": "dataset/test/images/1430.jpg",
389
+ "H": 2160,
390
+ "W": 3840,
391
+ "t_coarse_ms": 49.46706164628267,
392
+ "t_fine_ms": 440.50635304301977,
393
+ "t_total_ms": 489.97341468930244
394
+ },
395
+ {
396
+ "path": "dataset/test/images/1437.jpg",
397
+ "H": 2160,
398
+ "W": 3840,
399
+ "t_coarse_ms": 44.33557949960232,
400
+ "t_fine_ms": 425.30061211436987,
401
+ "t_total_ms": 469.6361916139722
402
+ },
403
+ {
404
+ "path": "dataset/test/images/1438.jpg",
405
+ "H": 2160,
406
+ "W": 3840,
407
+ "t_coarse_ms": 44.27209869027138,
408
+ "t_fine_ms": 425.7898461073637,
409
+ "t_total_ms": 470.0619447976351
410
+ },
411
+ {
412
+ "path": "dataset/test/images/1443.jpg",
413
+ "H": 2160,
414
+ "W": 3840,
415
+ "t_coarse_ms": 45.066650956869125,
416
+ "t_fine_ms": 425.2707865089178,
417
+ "t_total_ms": 470.33743746578693
418
+ },
419
+ {
420
+ "path": "dataset/test/images/1467.jpg",
421
+ "H": 2160,
422
+ "W": 3840,
423
+ "t_coarse_ms": 44.44928374141455,
424
+ "t_fine_ms": 425.61439611017704,
425
+ "t_total_ms": 470.0636798515916
426
+ },
427
+ {
428
+ "path": "dataset/test/images/147.jpg",
429
+ "H": 5120,
430
+ "W": 3840,
431
+ "t_coarse_ms": 60.642157681286335,
432
+ "t_fine_ms": 854.3515391647816,
433
+ "t_total_ms": 914.9936968460679
434
+ },
435
+ {
436
+ "path": "dataset/test/images/1471.jpg",
437
+ "H": 2160,
438
+ "W": 3840,
439
+ "t_coarse_ms": 51.92858260124922,
440
+ "t_fine_ms": 430.7840187102556,
441
+ "t_total_ms": 482.71260131150484
442
+ },
443
+ {
444
+ "path": "dataset/test/images/1477.jpg",
445
+ "H": 2160,
446
+ "W": 3840,
447
+ "t_coarse_ms": 44.527141377329826,
448
+ "t_fine_ms": 425.5507346242666,
449
+ "t_total_ms": 470.07787600159645
450
+ },
451
+ {
452
+ "path": "dataset/test/images/1494.jpg",
453
+ "H": 2160,
454
+ "W": 3840,
455
+ "t_coarse_ms": 44.46072597056627,
456
+ "t_fine_ms": 425.22873543202877,
457
+ "t_total_ms": 469.68946140259504
458
+ },
459
+ {
460
+ "path": "dataset/test/images/1495.jpg",
461
+ "H": 2160,
462
+ "W": 3840,
463
+ "t_coarse_ms": 44.32813450694084,
464
+ "t_fine_ms": 425.8275981992483,
465
+ "t_total_ms": 470.15573270618916
466
+ },
467
+ {
468
+ "path": "dataset/test/images/1509.jpg",
469
+ "H": 2160,
470
+ "W": 3840,
471
+ "t_coarse_ms": 49.085491336882114,
472
+ "t_fine_ms": 441.00978318601847,
473
+ "t_total_ms": 490.0952745229006
474
+ },
475
+ {
476
+ "path": "dataset/test/images/1512.jpg",
477
+ "H": 2160,
478
+ "W": 3840,
479
+ "t_coarse_ms": 46.05328291654587,
480
+ "t_fine_ms": 425.8631756529212,
481
+ "t_total_ms": 471.91645856946707
482
+ },
483
+ {
484
+ "path": "dataset/test/images/1517.jpg",
485
+ "H": 2160,
486
+ "W": 3840,
487
+ "t_coarse_ms": 46.347870491445065,
488
+ "t_fine_ms": 425.39719492197037,
489
+ "t_total_ms": 471.74506541341543
490
+ },
491
+ {
492
+ "path": "dataset/test/images/1519.jpg",
493
+ "H": 2160,
494
+ "W": 3840,
495
+ "t_coarse_ms": 50.81711243838072,
496
+ "t_fine_ms": 442.14620999991894,
497
+ "t_total_ms": 492.96332243829966
498
+ },
499
+ {
500
+ "path": "dataset/test/images/1526.jpg",
501
+ "H": 2160,
502
+ "W": 3840,
503
+ "t_coarse_ms": 44.26529724150896,
504
+ "t_fine_ms": 431.89835362136364,
505
+ "t_total_ms": 476.1636508628726
506
+ },
507
+ {
508
+ "path": "dataset/test/images/1555.jpg",
509
+ "H": 2160,
510
+ "W": 3840,
511
+ "t_coarse_ms": 46.30592092871666,
512
+ "t_fine_ms": 425.4487631842494,
513
+ "t_total_ms": 471.75468411296606
514
+ },
515
+ {
516
+ "path": "dataset/test/images/1564.jpg",
517
+ "H": 2160,
518
+ "W": 3840,
519
+ "t_coarse_ms": 44.196576811373234,
520
+ "t_fine_ms": 425.60188192874193,
521
+ "t_total_ms": 469.79845874011517
522
+ },
523
+ {
524
+ "path": "dataset/test/images/1573.jpg",
525
+ "H": 2160,
526
+ "W": 3840,
527
+ "t_coarse_ms": 45.87449599057436,
528
+ "t_fine_ms": 425.95503851771355,
529
+ "t_total_ms": 471.8295345082879
530
+ },
531
+ {
532
+ "path": "dataset/test/images/1584.jpg",
533
+ "H": 2160,
534
+ "W": 3840,
535
+ "t_coarse_ms": 46.40835523605347,
536
+ "t_fine_ms": 425.66053196787834,
537
+ "t_total_ms": 472.0688872039318
538
+ },
539
+ {
540
+ "path": "dataset/test/images/1613.jpg",
541
+ "H": 2160,
542
+ "W": 3840,
543
+ "t_coarse_ms": 51.01882200688124,
544
+ "t_fine_ms": 441.87348522245884,
545
+ "t_total_ms": 492.8923072293401
546
+ },
547
+ {
548
+ "path": "dataset/test/images/162.jpg",
549
+ "H": 4096,
550
+ "W": 3076,
551
+ "t_coarse_ms": 48.91088139265776,
552
+ "t_fine_ms": 597.2837572917342,
553
+ "t_total_ms": 646.194638684392
554
+ },
555
+ {
556
+ "path": "dataset/test/images/1620.jpg",
557
+ "H": 2160,
558
+ "W": 3840,
559
+ "t_coarse_ms": 51.63821205496788,
560
+ "t_fine_ms": 446.9916420057416,
561
+ "t_total_ms": 498.6298540607095
562
+ },
563
+ {
564
+ "path": "dataset/test/images/1625.jpg",
565
+ "H": 2160,
566
+ "W": 3840,
567
+ "t_coarse_ms": 46.11311759799719,
568
+ "t_fine_ms": 425.93891732394695,
569
+ "t_total_ms": 472.05203492194414
570
+ },
571
+ {
572
+ "path": "dataset/test/images/1627.jpg",
573
+ "H": 2160,
574
+ "W": 3840,
575
+ "t_coarse_ms": 46.20691388845444,
576
+ "t_fine_ms": 425.6671043112874,
577
+ "t_total_ms": 471.87401819974184
578
+ },
579
+ {
580
+ "path": "dataset/test/images/1637.jpg",
581
+ "H": 2160,
582
+ "W": 3840,
583
+ "t_coarse_ms": 44.613003730773926,
584
+ "t_fine_ms": 432.623403146863,
585
+ "t_total_ms": 477.2364068776369
586
+ },
587
+ {
588
+ "path": "dataset/test/images/164.jpg",
589
+ "H": 2031,
590
+ "W": 2048,
591
+ "t_coarse_ms": 39.84102141112089,
592
+ "t_fine_ms": 263.8954659923911,
593
+ "t_total_ms": 303.736487403512
594
+ },
595
+ {
596
+ "path": "dataset/test/images/1641.jpg",
597
+ "H": 2160,
598
+ "W": 3840,
599
+ "t_coarse_ms": 46.18293885141611,
600
+ "t_fine_ms": 442.7359029650688,
601
+ "t_total_ms": 488.9188418164849
602
+ },
603
+ {
604
+ "path": "dataset/test/images/1645.jpg",
605
+ "H": 2160,
606
+ "W": 3840,
607
+ "t_coarse_ms": 44.53704971820116,
608
+ "t_fine_ms": 432.44697991758585,
609
+ "t_total_ms": 476.984029635787
610
+ },
611
+ {
612
+ "path": "dataset/test/images/1646.jpg",
613
+ "H": 2160,
614
+ "W": 3840,
615
+ "t_coarse_ms": 46.3264100253582,
616
+ "t_fine_ms": 425.7882731035352,
617
+ "t_total_ms": 472.1146831288934
618
+ },
619
+ {
620
+ "path": "dataset/test/images/1649.jpg",
621
+ "H": 2160,
622
+ "W": 3840,
623
+ "t_coarse_ms": 44.47484202682972,
624
+ "t_fine_ms": 425.9179290384054,
625
+ "t_total_ms": 470.39277106523514
626
+ },
627
+ {
628
+ "path": "dataset/test/images/1652.jpg",
629
+ "H": 2160,
630
+ "W": 3840,
631
+ "t_coarse_ms": 44.276428408920765,
632
+ "t_fine_ms": 426.04100052267313,
633
+ "t_total_ms": 470.3174289315939
634
+ },
635
+ {
636
+ "path": "dataset/test/images/1654.jpg",
637
+ "H": 2160,
638
+ "W": 3840,
639
+ "t_coarse_ms": 44.503225944936275,
640
+ "t_fine_ms": 425.6558632478118,
641
+ "t_total_ms": 470.15908919274807
642
+ },
643
+ {
644
+ "path": "dataset/test/images/1656.jpg",
645
+ "H": 2160,
646
+ "W": 3840,
647
+ "t_coarse_ms": 44.46195811033249,
648
+ "t_fine_ms": 425.61220191419125,
649
+ "t_total_ms": 470.07416002452374
650
+ },
651
+ {
652
+ "path": "dataset/test/images/179.jpg",
653
+ "H": 5120,
654
+ "W": 3329,
655
+ "t_coarse_ms": 57.7998012304306,
656
+ "t_fine_ms": 726.3155784457922,
657
+ "t_total_ms": 784.1153796762228
658
+ },
659
+ {
660
+ "path": "dataset/test/images/187.jpg",
661
+ "H": 2000,
662
+ "W": 3008,
663
+ "t_coarse_ms": 48.47842454910278,
664
+ "t_fine_ms": 349.3953961879015,
665
+ "t_total_ms": 397.8738207370043
666
+ },
667
+ {
668
+ "path": "dataset/test/images/190.jpg",
669
+ "H": 2950,
670
+ "W": 4096,
671
+ "t_coarse_ms": 62.61407397687435,
672
+ "t_fine_ms": 597.2697408869863,
673
+ "t_total_ms": 659.8838148638606
674
+ },
675
+ {
676
+ "path": "dataset/test/images/192.jpg",
677
+ "H": 3432,
678
+ "W": 5120,
679
+ "t_coarse_ms": 83.65485444664955,
680
+ "t_fine_ms": 723.987290635705,
681
+ "t_total_ms": 807.6421450823545
682
+ },
683
+ {
684
+ "path": "dataset/test/images/199.jpg",
685
+ "H": 3120,
686
+ "W": 4160,
687
+ "t_coarse_ms": 59.46696922183037,
688
+ "t_fine_ms": 604.2781788855791,
689
+ "t_total_ms": 663.7451481074095
690
+ },
691
+ {
692
+ "path": "dataset/test/images/207.jpg",
693
+ "H": 4000,
694
+ "W": 6000,
695
+ "t_coarse_ms": 97.90519066154957,
696
+ "t_fine_ms": 1052.1979937329888,
697
+ "t_total_ms": 1150.1031843945384
698
+ },
699
+ {
700
+ "path": "dataset/test/images/210.jpg",
701
+ "H": 3840,
702
+ "W": 5120,
703
+ "t_coarse_ms": 68.98264214396477,
704
+ "t_fine_ms": 906.2781864777207,
705
+ "t_total_ms": 975.2608286216855
706
+ },
707
+ {
708
+ "path": "dataset/test/images/225.jpg",
709
+ "H": 4949,
710
+ "W": 7414,
711
+ "t_coarse_ms": 129.05451282858849,
712
+ "t_fine_ms": 1618.8234062865376,
713
+ "t_total_ms": 1747.8779191151261
714
+ },
715
+ {
716
+ "path": "dataset/test/images/229.jpg",
717
+ "H": 2266,
718
+ "W": 4032,
719
+ "t_coarse_ms": 61.07564736157656,
720
+ "t_fine_ms": 457.3208214715123,
721
+ "t_total_ms": 518.3964688330889
722
+ },
723
+ {
724
+ "path": "dataset/test/images/235.jpg",
725
+ "H": 3918,
726
+ "W": 3007,
727
+ "t_coarse_ms": 54.62324991822243,
728
+ "t_fine_ms": 597.5406132638454,
729
+ "t_total_ms": 652.1638631820679
730
+ },
731
+ {
732
+ "path": "dataset/test/images/24.jpg",
733
+ "H": 4480,
734
+ "W": 6720,
735
+ "t_coarse_ms": 113.26604150235653,
736
+ "t_fine_ms": 1206.9092076271772,
737
+ "t_total_ms": 1320.1752491295338
738
+ },
739
+ {
740
+ "path": "dataset/test/images/256.jpg",
741
+ "H": 4413,
742
+ "W": 6503,
743
+ "t_coarse_ms": 114.3032219260931,
744
+ "t_fine_ms": 1209.4936883077025,
745
+ "t_total_ms": 1323.7969102337956
746
+ },
747
+ {
748
+ "path": "dataset/test/images/284.jpg",
749
+ "H": 1536,
750
+ "W": 2048,
751
+ "t_coarse_ms": 49.63542893528938,
752
+ "t_fine_ms": 184.62779838591814,
753
+ "t_total_ms": 234.26322732120752
754
+ },
755
+ {
756
+ "path": "dataset/test/images/286.jpg",
757
+ "H": 2181,
758
+ "W": 3696,
759
+ "t_coarse_ms": 45.70193123072386,
760
+ "t_fine_ms": 359.05792471021414,
761
+ "t_total_ms": 404.759855940938
762
+ },
763
+ {
764
+ "path": "dataset/test/images/293.jpg",
765
+ "H": 5000,
766
+ "W": 4000,
767
+ "t_coarse_ms": 61.05856504291296,
768
+ "t_fine_ms": 854.7191014513373,
769
+ "t_total_ms": 915.7776664942503
770
+ },
771
+ {
772
+ "path": "dataset/test/images/314.jpg",
773
+ "H": 2448,
774
+ "W": 3264,
775
+ "t_coarse_ms": 52.63520497828722,
776
+ "t_fine_ms": 358.31248853355646,
777
+ "t_total_ms": 410.9476935118437
778
+ },
779
+ {
780
+ "path": "dataset/test/images/319.jpg",
781
+ "H": 2880,
782
+ "W": 1920,
783
+ "t_coarse_ms": 41.29869304597378,
784
+ "t_fine_ms": 239.4571378827095,
785
+ "t_total_ms": 280.7558309286833
786
+ },
787
+ {
788
+ "path": "dataset/test/images/327.jpg",
789
+ "H": 1536,
790
+ "W": 2048,
791
+ "t_coarse_ms": 39.28858693689108,
792
+ "t_fine_ms": 173.61029889434576,
793
+ "t_total_ms": 212.89888583123684
794
+ },
795
+ {
796
+ "path": "dataset/test/images/328.jpg",
797
+ "H": 1200,
798
+ "W": 1600,
799
+ "t_coarse_ms": 37.74308692663908,
800
+ "t_fine_ms": 116.70985817909241,
801
+ "t_total_ms": 154.4529451057315
802
+ },
803
+ {
804
+ "path": "dataset/test/images/334.jpg",
805
+ "H": 1536,
806
+ "W": 1454,
807
+ "t_coarse_ms": 38.21551986038685,
808
+ "t_fine_ms": 117.12666414678097,
809
+ "t_total_ms": 155.34218400716782
810
+ },
811
+ {
812
+ "path": "dataset/test/images/335.jpg",
813
+ "H": 1536,
814
+ "W": 2048,
815
+ "t_coarse_ms": 38.858684711158276,
816
+ "t_fine_ms": 173.57138637453318,
817
+ "t_total_ms": 212.43007108569145
818
+ },
819
+ {
820
+ "path": "dataset/test/images/351.jpg",
821
+ "H": 3024,
822
+ "W": 4032,
823
+ "t_coarse_ms": 51.323678344488144,
824
+ "t_fine_ms": 572.3359966650605,
825
+ "t_total_ms": 623.6596750095487
826
+ },
827
+ {
828
+ "path": "dataset/test/images/394.jpg",
829
+ "H": 5616,
830
+ "W": 3744,
831
+ "t_coarse_ms": 67.69207399338484,
832
+ "t_fine_ms": 1041.8661190196872,
833
+ "t_total_ms": 1109.558193013072
834
+ },
835
+ {
836
+ "path": "dataset/test/images/408.jpg",
837
+ "H": 4016,
838
+ "W": 6016,
839
+ "t_coarse_ms": 75.17607882618904,
840
+ "t_fine_ms": 1054.2822405695915,
841
+ "t_total_ms": 1129.4583193957806
842
+ },
843
+ {
844
+ "path": "dataset/test/images/430.jpg",
845
+ "H": 2160,
846
+ "W": 3840,
847
+ "t_coarse_ms": 54.189229384064674,
848
+ "t_fine_ms": 442.5941063091159,
849
+ "t_total_ms": 496.78333569318056
850
+ },
851
+ {
852
+ "path": "dataset/test/images/433.jpg",
853
+ "H": 2160,
854
+ "W": 3840,
855
+ "t_coarse_ms": 46.143404208123684,
856
+ "t_fine_ms": 426.29740573465824,
857
+ "t_total_ms": 472.4408099427819
858
+ },
859
+ {
860
+ "path": "dataset/test/images/436.jpg",
861
+ "H": 2160,
862
+ "W": 3840,
863
+ "t_coarse_ms": 44.87194120883942,
864
+ "t_fine_ms": 426.4885978773236,
865
+ "t_total_ms": 471.36053908616304
866
+ },
867
+ {
868
+ "path": "dataset/test/images/441.jpg",
869
+ "H": 2160,
870
+ "W": 3840,
871
+ "t_coarse_ms": 44.54675782471895,
872
+ "t_fine_ms": 430.34669291228056,
873
+ "t_total_ms": 474.8934507369995
874
+ },
875
+ {
876
+ "path": "dataset/test/images/448.jpg",
877
+ "H": 2160,
878
+ "W": 3840,
879
+ "t_coarse_ms": 46.59396503120661,
880
+ "t_fine_ms": 425.83730537444353,
881
+ "t_total_ms": 472.43127040565014
882
+ },
883
+ {
884
+ "path": "dataset/test/images/450.jpg",
885
+ "H": 2160,
886
+ "W": 3840,
887
+ "t_coarse_ms": 44.50656287372112,
888
+ "t_fine_ms": 426.06744077056646,
889
+ "t_total_ms": 470.5740036442876
890
+ },
891
+ {
892
+ "path": "dataset/test/images/452.jpg",
893
+ "H": 2160,
894
+ "W": 3840,
895
+ "t_coarse_ms": 46.207514591515064,
896
+ "t_fine_ms": 425.85232481360435,
897
+ "t_total_ms": 472.0598394051194
898
+ },
899
+ {
900
+ "path": "dataset/test/images/458.jpg",
901
+ "H": 2160,
902
+ "W": 3840,
903
+ "t_coarse_ms": 44.56426203250885,
904
+ "t_fine_ms": 426.02418921887875,
905
+ "t_total_ms": 470.5884512513876
906
+ },
907
+ {
908
+ "path": "dataset/test/images/467.jpg",
909
+ "H": 2160,
910
+ "W": 3840,
911
+ "t_coarse_ms": 44.376797042787075,
912
+ "t_fine_ms": 426.39733385294676,
913
+ "t_total_ms": 470.77413089573383
914
+ },
915
+ {
916
+ "path": "dataset/test/images/470.jpg",
917
+ "H": 2160,
918
+ "W": 3840,
919
+ "t_coarse_ms": 44.988992623984814,
920
+ "t_fine_ms": 425.94566103070974,
921
+ "t_total_ms": 470.93465365469456
922
+ },
923
+ {
924
+ "path": "dataset/test/images/477.jpg",
925
+ "H": 2160,
926
+ "W": 3840,
927
+ "t_coarse_ms": 46.57909646630287,
928
+ "t_fine_ms": 426.0811973363161,
929
+ "t_total_ms": 472.660293802619
930
+ },
931
+ {
932
+ "path": "dataset/test/images/502.jpg",
933
+ "H": 2160,
934
+ "W": 3840,
935
+ "t_coarse_ms": 44.710809364914894,
936
+ "t_fine_ms": 425.2654956653714,
937
+ "t_total_ms": 469.9763050302863
938
+ },
939
+ {
940
+ "path": "dataset/test/images/506.jpg",
941
+ "H": 2160,
942
+ "W": 3840,
943
+ "t_coarse_ms": 46.35640699416399,
944
+ "t_fine_ms": 425.3169922158122,
945
+ "t_total_ms": 471.6733992099762
946
+ },
947
+ {
948
+ "path": "dataset/test/images/515.jpg",
949
+ "H": 2160,
950
+ "W": 3840,
951
+ "t_coarse_ms": 44.61330361664295,
952
+ "t_fine_ms": 426.2756546959281,
953
+ "t_total_ms": 470.88895831257105
954
+ },
955
+ {
956
+ "path": "dataset/test/images/52.jpg",
957
+ "H": 5304,
958
+ "W": 7952,
959
+ "t_coarse_ms": 90.57098720222712,
960
+ "t_fine_ms": 1631.9165751338005,
961
+ "t_total_ms": 1722.4875623360276
962
+ },
963
+ {
964
+ "path": "dataset/test/images/539.jpg",
965
+ "H": 2160,
966
+ "W": 3840,
967
+ "t_coarse_ms": 62.35641706734896,
968
+ "t_fine_ms": 456.4879275858402,
969
+ "t_total_ms": 518.8443446531892
970
+ },
971
+ {
972
+ "path": "dataset/test/images/542.jpg",
973
+ "H": 2160,
974
+ "W": 3840,
975
+ "t_coarse_ms": 45.9717083722353,
976
+ "t_fine_ms": 426.0638039559126,
977
+ "t_total_ms": 472.0355123281479
978
+ },
979
+ {
980
+ "path": "dataset/test/images/543.jpg",
981
+ "H": 2160,
982
+ "W": 3840,
983
+ "t_coarse_ms": 44.45484559983015,
984
+ "t_fine_ms": 425.5034951493144,
985
+ "t_total_ms": 469.95834074914455
986
+ },
987
+ {
988
+ "path": "dataset/test/images/547.jpg",
989
+ "H": 2160,
990
+ "W": 3840,
991
+ "t_coarse_ms": 44.5246072486043,
992
+ "t_fine_ms": 430.0335319712758,
993
+ "t_total_ms": 474.5581392198801
994
+ },
995
+ {
996
+ "path": "dataset/test/images/549.jpg",
997
+ "H": 2160,
998
+ "W": 3840,
999
+ "t_coarse_ms": 46.08479421585798,
1000
+ "t_fine_ms": 425.99701788276434,
1001
+ "t_total_ms": 472.0818120986223
1002
+ },
1003
+ {
1004
+ "path": "dataset/test/images/55.jpg",
1005
+ "H": 5304,
1006
+ "W": 7952,
1007
+ "t_coarse_ms": 137.40360271185637,
1008
+ "t_fine_ms": 1632.2561670094728,
1009
+ "t_total_ms": 1769.6597697213292
1010
+ },
1011
+ {
1012
+ "path": "dataset/test/images/553.jpg",
1013
+ "H": 2160,
1014
+ "W": 3840,
1015
+ "t_coarse_ms": 62.03949823975563,
1016
+ "t_fine_ms": 455.29425237327814,
1017
+ "t_total_ms": 517.3337506130338
1018
+ },
1019
+ {
1020
+ "path": "dataset/test/images/564.jpg",
1021
+ "H": 2160,
1022
+ "W": 3840,
1023
+ "t_coarse_ms": 44.79507729411125,
1024
+ "t_fine_ms": 425.9400703012943,
1025
+ "t_total_ms": 470.7351475954056
1026
+ },
1027
+ {
1028
+ "path": "dataset/test/images/570.jpg",
1029
+ "H": 2160,
1030
+ "W": 3840,
1031
+ "t_coarse_ms": 44.7114696726203,
1032
+ "t_fine_ms": 426.00927129387856,
1033
+ "t_total_ms": 470.72074096649885
1034
+ },
1035
+ {
1036
+ "path": "dataset/test/images/593.jpg",
1037
+ "H": 2160,
1038
+ "W": 3840,
1039
+ "t_coarse_ms": 46.30522895604372,
1040
+ "t_fine_ms": 426.32691096514463,
1041
+ "t_total_ms": 472.63213992118835
1042
+ },
1043
+ {
1044
+ "path": "dataset/test/images/601.jpg",
1045
+ "H": 2160,
1046
+ "W": 3840,
1047
+ "t_coarse_ms": 46.576643362641335,
1048
+ "t_fine_ms": 425.803923048079,
1049
+ "t_total_ms": 472.38056641072035
1050
+ },
1051
+ {
1052
+ "path": "dataset/test/images/62.jpg",
1053
+ "H": 6000,
1054
+ "W": 4000,
1055
+ "t_coarse_ms": 67.04008299857378,
1056
+ "t_fine_ms": 1060.5956250801682,
1057
+ "t_total_ms": 1127.635708078742
1058
+ },
1059
+ {
1060
+ "path": "dataset/test/images/645.jpg",
1061
+ "H": 2160,
1062
+ "W": 3840,
1063
+ "t_coarse_ms": 55.916463024914265,
1064
+ "t_fine_ms": 449.9956350773573,
1065
+ "t_total_ms": 505.91209810227156
1066
+ },
1067
+ {
1068
+ "path": "dataset/test/images/647.jpg",
1069
+ "H": 2160,
1070
+ "W": 3840,
1071
+ "t_coarse_ms": 46.77173122763634,
1072
+ "t_fine_ms": 425.986448302865,
1073
+ "t_total_ms": 472.75817953050137
1074
+ },
1075
+ {
1076
+ "path": "dataset/test/images/66.jpg",
1077
+ "H": 6000,
1078
+ "W": 4000,
1079
+ "t_coarse_ms": 73.23215808719397,
1080
+ "t_fine_ms": 1049.5763514190912,
1081
+ "t_total_ms": 1122.8085095062852
1082
+ },
1083
+ {
1084
+ "path": "dataset/test/images/665.jpg",
1085
+ "H": 2160,
1086
+ "W": 3840,
1087
+ "t_coarse_ms": 54.276746697723866,
1088
+ "t_fine_ms": 450.46883821487427,
1089
+ "t_total_ms": 504.74558491259813
1090
+ },
1091
+ {
1092
+ "path": "dataset/test/images/690.jpg",
1093
+ "H": 2160,
1094
+ "W": 3840,
1095
+ "t_coarse_ms": 44.47704553604126,
1096
+ "t_fine_ms": 442.30098370462656,
1097
+ "t_total_ms": 486.7780292406678
1098
+ },
1099
+ {
1100
+ "path": "dataset/test/images/697.jpg",
1101
+ "H": 2160,
1102
+ "W": 3840,
1103
+ "t_coarse_ms": 44.456567615270615,
1104
+ "t_fine_ms": 430.75701780617237,
1105
+ "t_total_ms": 475.213585421443
1106
+ },
1107
+ {
1108
+ "path": "dataset/test/images/705.jpg",
1109
+ "H": 2160,
1110
+ "W": 3840,
1111
+ "t_coarse_ms": 46.252891421318054,
1112
+ "t_fine_ms": 426.39773432165384,
1113
+ "t_total_ms": 472.6506257429719
1114
+ },
1115
+ {
1116
+ "path": "dataset/test/images/728.jpg",
1117
+ "H": 2160,
1118
+ "W": 3840,
1119
+ "t_coarse_ms": 44.85049098730087,
1120
+ "t_fine_ms": 426.2953819707036,
1121
+ "t_total_ms": 471.1458729580045
1122
+ },
1123
+ {
1124
+ "path": "dataset/test/images/736.jpg",
1125
+ "H": 2160,
1126
+ "W": 3840,
1127
+ "t_coarse_ms": 46.267238445580006,
1128
+ "t_fine_ms": 426.3408873230219,
1129
+ "t_total_ms": 472.6081257686019
1130
+ },
1131
+ {
1132
+ "path": "dataset/test/images/741.jpg",
1133
+ "H": 2160,
1134
+ "W": 3840,
1135
+ "t_coarse_ms": 44.61097065359354,
1136
+ "t_fine_ms": 426.5766916796565,
1137
+ "t_total_ms": 471.18766233325005
1138
+ },
1139
+ {
1140
+ "path": "dataset/test/images/742.jpg",
1141
+ "H": 2160,
1142
+ "W": 3840,
1143
+ "t_coarse_ms": 44.77288480848074,
1144
+ "t_fine_ms": 431.0416569933295,
1145
+ "t_total_ms": 475.81454180181026
1146
+ },
1147
+ {
1148
+ "path": "dataset/test/images/748.jpg",
1149
+ "H": 2160,
1150
+ "W": 3840,
1151
+ "t_coarse_ms": 46.498934738337994,
1152
+ "t_fine_ms": 426.042053848505,
1153
+ "t_total_ms": 472.540988586843
1154
+ },
1155
+ {
1156
+ "path": "dataset/test/images/759.jpg",
1157
+ "H": 2160,
1158
+ "W": 3840,
1159
+ "t_coarse_ms": 44.73839979618788,
1160
+ "t_fine_ms": 425.9616816416383,
1161
+ "t_total_ms": 470.70008143782616
1162
+ },
1163
+ {
1164
+ "path": "dataset/test/images/776.jpg",
1165
+ "H": 2160,
1166
+ "W": 3840,
1167
+ "t_coarse_ms": 44.587114825844765,
1168
+ "t_fine_ms": 426.11830681562424,
1169
+ "t_total_ms": 470.705421641469
1170
+ },
1171
+ {
1172
+ "path": "dataset/test/images/778.jpg",
1173
+ "H": 2160,
1174
+ "W": 3840,
1175
+ "t_coarse_ms": 44.326301664114,
1176
+ "t_fine_ms": 426.18415132164955,
1177
+ "t_total_ms": 470.51045298576355
1178
+ },
1179
+ {
1180
+ "path": "dataset/test/images/779.jpg",
1181
+ "H": 2160,
1182
+ "W": 3840,
1183
+ "t_coarse_ms": 44.7318684309721,
1184
+ "t_fine_ms": 426.0721895843744,
1185
+ "t_total_ms": 470.8040580153465
1186
+ },
1187
+ {
1188
+ "path": "dataset/test/images/782.jpg",
1189
+ "H": 2160,
1190
+ "W": 3840,
1191
+ "t_coarse_ms": 46.11456021666527,
1192
+ "t_fine_ms": 426.14081874489784,
1193
+ "t_total_ms": 472.2553789615631
1194
+ },
1195
+ {
1196
+ "path": "dataset/test/images/789.jpg",
1197
+ "H": 2160,
1198
+ "W": 3840,
1199
+ "t_coarse_ms": 44.51038967818022,
1200
+ "t_fine_ms": 426.36278830468655,
1201
+ "t_total_ms": 470.87317798286676
1202
+ },
1203
+ {
1204
+ "path": "dataset/test/images/811.jpg",
1205
+ "H": 2160,
1206
+ "W": 3840,
1207
+ "t_coarse_ms": 44.75479107350111,
1208
+ "t_fine_ms": 425.8342310786247,
1209
+ "t_total_ms": 470.58902215212584
1210
+ },
1211
+ {
1212
+ "path": "dataset/test/images/818.jpg",
1213
+ "H": 2160,
1214
+ "W": 3840,
1215
+ "t_coarse_ms": 44.49161421507597,
1216
+ "t_fine_ms": 426.4873741194606,
1217
+ "t_total_ms": 470.97898833453655
1218
+ },
1219
+ {
1220
+ "path": "dataset/test/images/822.jpg",
1221
+ "H": 2160,
1222
+ "W": 3840,
1223
+ "t_coarse_ms": 44.6783471852541,
1224
+ "t_fine_ms": 425.7477568462491,
1225
+ "t_total_ms": 470.4261040315032
1226
+ },
1227
+ {
1228
+ "path": "dataset/test/images/860.jpg",
1229
+ "H": 2160,
1230
+ "W": 3840,
1231
+ "t_coarse_ms": 46.14970646798611,
1232
+ "t_fine_ms": 426.2132756412029,
1233
+ "t_total_ms": 472.36298210918903
1234
+ },
1235
+ {
1236
+ "path": "dataset/test/images/865.jpg",
1237
+ "H": 2160,
1238
+ "W": 3840,
1239
+ "t_coarse_ms": 44.77647226303816,
1240
+ "t_fine_ms": 426.045180298388,
1241
+ "t_total_ms": 470.82165256142616
1242
+ },
1243
+ {
1244
+ "path": "dataset/test/images/866.jpg",
1245
+ "H": 2160,
1246
+ "W": 3840,
1247
+ "t_coarse_ms": 44.464342296123505,
1248
+ "t_fine_ms": 433.3420917391777,
1249
+ "t_total_ms": 477.8064340353012
1250
+ },
1251
+ {
1252
+ "path": "dataset/test/images/878.jpg",
1253
+ "H": 2160,
1254
+ "W": 3840,
1255
+ "t_coarse_ms": 44.68281473964453,
1256
+ "t_fine_ms": 442.3503763973713,
1257
+ "t_total_ms": 487.0331911370158
1258
+ },
1259
+ {
1260
+ "path": "dataset/test/images/89.jpg",
1261
+ "H": 4496,
1262
+ "W": 3000,
1263
+ "t_coarse_ms": 53.19163575768471,
1264
+ "t_fine_ms": 577.3740643635392,
1265
+ "t_total_ms": 630.5657001212239
1266
+ },
1267
+ {
1268
+ "path": "dataset/test/images/920.jpg",
1269
+ "H": 2160,
1270
+ "W": 3840,
1271
+ "t_coarse_ms": 51.456608809530735,
1272
+ "t_fine_ms": 442.13218335062265,
1273
+ "t_total_ms": 493.5887921601534
1274
+ },
1275
+ {
1276
+ "path": "dataset/test/images/929.jpg",
1277
+ "H": 2160,
1278
+ "W": 3840,
1279
+ "t_coarse_ms": 46.35206889361143,
1280
+ "t_fine_ms": 426.0200811550021,
1281
+ "t_total_ms": 472.37215004861355
1282
+ },
1283
+ {
1284
+ "path": "dataset/test/images/94.jpg",
1285
+ "H": 4613,
1286
+ "W": 2595,
1287
+ "t_coarse_ms": 49.010117538273335,
1288
+ "t_fine_ms": 539.7742157801986,
1289
+ "t_total_ms": 588.7843333184719
1290
+ },
1291
+ {
1292
+ "path": "dataset/test/images/940.jpg",
1293
+ "H": 2160,
1294
+ "W": 3840,
1295
+ "t_coarse_ms": 53.503746166825294,
1296
+ "t_fine_ms": 445.8295265212655,
1297
+ "t_total_ms": 499.3332726880908
1298
+ },
1299
+ {
1300
+ "path": "dataset/test/images/941.jpg",
1301
+ "H": 2160,
1302
+ "W": 3840,
1303
+ "t_coarse_ms": 46.16930242627859,
1304
+ "t_fine_ms": 426.11860763281584,
1305
+ "t_total_ms": 472.28791005909443
1306
+ },
1307
+ {
1308
+ "path": "dataset/test/images/947.jpg",
1309
+ "H": 2160,
1310
+ "W": 3840,
1311
+ "t_coarse_ms": 46.44507262855768,
1312
+ "t_fine_ms": 425.8964592590928,
1313
+ "t_total_ms": 472.3415318876505
1314
+ },
1315
+ {
1316
+ "path": "dataset/test/images/959.jpg",
1317
+ "H": 2160,
1318
+ "W": 3840,
1319
+ "t_coarse_ms": 44.70463655889034,
1320
+ "t_fine_ms": 426.38475075364113,
1321
+ "t_total_ms": 471.08938731253147
1322
+ },
1323
+ {
1324
+ "path": "dataset/test/images/97.jpg",
1325
+ "H": 6000,
1326
+ "W": 4000,
1327
+ "t_coarse_ms": 93.69281399995089,
1328
+ "t_fine_ms": 1047.9462426155806,
1329
+ "t_total_ms": 1141.6390566155314
1330
+ }
1331
+ ]
1332
+ }
scripts/export_onnx_trt.py CHANGED
@@ -9,6 +9,7 @@ import torch
9
  import tensorrt as trt
10
 
11
  from src.wireseghr.model import WireSegHR
 
12
 
13
 
14
  class CoarseModule(torch.nn.Module):
@@ -63,13 +64,13 @@ def main():
63
 
64
  ckpt_path = args.ckpt if args.ckpt else cfg.get("resume", "")
65
  if ckpt_path:
66
- assert os.path.isfile(ckpt_path), f"Checkpoint not found: {ckpt_path}"
67
  print(f"[export] Loading checkpoint: {ckpt_path}")
68
  state = torch.load(ckpt_path, map_location=device)
69
  model.load_state_dict(state["model"]) # expects dict with key 'model'
70
  model.eval()
71
 
72
- os.makedirs(args.out_dir, exist_ok=True)
73
 
74
  # Prepare dummy inputs (static shapes for best TRT performance)
75
  coarse_in = torch.randn(1, 6, args.coarse_size, args.coarse_size, device=device)
@@ -77,12 +78,12 @@ def main():
77
 
78
  # Coarse export
79
  coarse_wrapper = CoarseModule(model).to(device).eval()
80
- coarse_onnx = os.path.join(args.out_dir, f"wireseghr_coarse_{args.coarse_size}.onnx")
81
  print(f"[export] Exporting COARSE to {coarse_onnx}")
82
  torch.onnx.export(
83
  coarse_wrapper,
84
  coarse_in,
85
- coarse_onnx,
86
  export_params=True,
87
  opset_version=args.opset,
88
  do_constant_folding=True,
@@ -94,12 +95,12 @@ def main():
94
 
95
  # Fine export
96
  fine_wrapper = FineModule(model).to(device).eval()
97
- fine_onnx = os.path.join(args.out_dir, f"wireseghr_fine_{args.fine_patch_size}.onnx")
98
  print(f"[export] Exporting FINE to {fine_onnx}")
99
  torch.onnx.export(
100
  fine_wrapper,
101
  fine_in,
102
- fine_onnx,
103
  export_params=True,
104
  opset_version=args.opset,
105
  do_constant_folding=True,
@@ -111,8 +112,8 @@ def main():
111
  # Optional TensorRT building via trtexec; fallback to Python API if unavailable
112
  if args.build_trt:
113
  trtexec_path = args.trtexec if args.trtexec else shutil.which("trtexec")
114
- coarse_engine = os.path.join(args.out_dir, f"wireseghr_coarse_{args.coarse_size}.engine")
115
- fine_engine = os.path.join(args.out_dir, f"wireseghr_fine_{args.fine_patch_size}.engine")
116
  if trtexec_path:
117
  def build_engine_cli(onnx_path: str, engine_path: str):
118
  print(f"[export] Building TRT engine (trtexec): {engine_path}")
@@ -125,8 +126,8 @@ def main():
125
  ]
126
  subprocess.run(cmd, check=True)
127
 
128
- build_engine_cli(coarse_onnx, coarse_engine)
129
- build_engine_cli(fine_onnx, fine_engine)
130
  else:
131
  print("[export] trtexec not found; building engines via TensorRT Python API")
132
 
@@ -135,7 +136,7 @@ def main():
135
  builder = trt.Builder(logger)
136
  network = builder.create_network(1 << int(trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH))
137
  parser = trt.OnnxParser(network, logger)
138
- with open(onnx_path, "rb") as f:
139
  data = f.read()
140
  ok = parser.parse(data)
141
  if not ok:
@@ -151,7 +152,7 @@ def main():
151
  print(f"[export] Building TRT engine (Python): {engine_path}")
152
  serialized = builder.build_serialized_network(network, config)
153
  assert serialized is not None, "Failed to build TensorRT engine"
154
- with open(engine_path, "wb") as f:
155
  f.write(serialized)
156
 
157
  build_engine_py(coarse_onnx, coarse_engine)
 
9
  import tensorrt as trt
10
 
11
  from src.wireseghr.model import WireSegHR
12
+ from pathlib import Path
13
 
14
 
15
  class CoarseModule(torch.nn.Module):
 
64
 
65
  ckpt_path = args.ckpt if args.ckpt else cfg.get("resume", "")
66
  if ckpt_path:
67
+ assert Path(ckpt_path).is_file(), f"Checkpoint not found: {ckpt_path}"
68
  print(f"[export] Loading checkpoint: {ckpt_path}")
69
  state = torch.load(ckpt_path, map_location=device)
70
  model.load_state_dict(state["model"]) # expects dict with key 'model'
71
  model.eval()
72
 
73
+ Path(args.out_dir).mkdir(parents=True, exist_ok=True)
74
 
75
  # Prepare dummy inputs (static shapes for best TRT performance)
76
  coarse_in = torch.randn(1, 6, args.coarse_size, args.coarse_size, device=device)
 
78
 
79
  # Coarse export
80
  coarse_wrapper = CoarseModule(model).to(device).eval()
81
+ coarse_onnx = Path(args.out_dir) / f"wireseghr_coarse_{args.coarse_size}.onnx"
82
  print(f"[export] Exporting COARSE to {coarse_onnx}")
83
  torch.onnx.export(
84
  coarse_wrapper,
85
  coarse_in,
86
+ str(coarse_onnx),
87
  export_params=True,
88
  opset_version=args.opset,
89
  do_constant_folding=True,
 
95
 
96
  # Fine export
97
  fine_wrapper = FineModule(model).to(device).eval()
98
+ fine_onnx = Path(args.out_dir) / f"wireseghr_fine_{args.fine_patch_size}.onnx"
99
  print(f"[export] Exporting FINE to {fine_onnx}")
100
  torch.onnx.export(
101
  fine_wrapper,
102
  fine_in,
103
+ str(fine_onnx),
104
  export_params=True,
105
  opset_version=args.opset,
106
  do_constant_folding=True,
 
112
  # Optional TensorRT building via trtexec; fallback to Python API if unavailable
113
  if args.build_trt:
114
  trtexec_path = args.trtexec if args.trtexec else shutil.which("trtexec")
115
+ coarse_engine = Path(args.out_dir) / f"wireseghr_coarse_{args.coarse_size}.engine"
116
+ fine_engine = Path(args.out_dir) / f"wireseghr_fine_{args.fine_patch_size}.engine"
117
  if trtexec_path:
118
  def build_engine_cli(onnx_path: str, engine_path: str):
119
  print(f"[export] Building TRT engine (trtexec): {engine_path}")
 
126
  ]
127
  subprocess.run(cmd, check=True)
128
 
129
+ build_engine_cli(str(coarse_onnx), str(coarse_engine))
130
+ build_engine_cli(str(fine_onnx), str(fine_engine))
131
  else:
132
  print("[export] trtexec not found; building engines via TensorRT Python API")
133
 
 
136
  builder = trt.Builder(logger)
137
  network = builder.create_network(1 << int(trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH))
138
  parser = trt.OnnxParser(network, logger)
139
+ with open(str(onnx_path), "rb") as f:
140
  data = f.read()
141
  ok = parser.parse(data)
142
  if not ok:
 
152
  print(f"[export] Building TRT engine (Python): {engine_path}")
153
  serialized = builder.build_serialized_network(network, config)
154
  assert serialized is not None, "Failed to build TensorRT engine"
155
+ with open(str(engine_path), "wb") as f:
156
  f.write(serialized)
157
 
158
  build_engine_py(coarse_onnx, coarse_engine)
scripts/pull_and_preprocess_wireseghr_dataset.py CHANGED
@@ -46,12 +46,10 @@ def list_files_with_paths(drive, folder_id, prefix=""):
46
  }
47
  for file in drive.ListFile(params).GetList():
48
  if file["mimeType"] == "application/vnd.google-apps.folder":
49
- sub_prefix = (
50
- os.path.join(prefix, file["title"]) if prefix else file["title"]
51
- )
52
  items += list_files_with_paths(drive, file["id"], sub_prefix)
53
  else:
54
- rel_path = os.path.join(prefix, file["title"]) if prefix else file["title"]
55
  size = int(file.get("fileSize", 0)) if "fileSize" in file else 0
56
  items.append(
57
  {
@@ -67,7 +65,7 @@ def list_files_with_paths(drive, folder_id, prefix=""):
67
 
68
  def download_folder(folder_id, dest, service_account_json, workers: int):
69
  drive = authenticate(service_account_json)
70
- os.makedirs(dest, exist_ok=True)
71
 
72
  print(f"Listing files in folder {folder_id}...")
73
  files_with_paths = list_files_with_paths(drive, folder_id)
@@ -78,16 +76,16 @@ def download_folder(folder_id, dest, service_account_json, workers: int):
78
  tasks = []
79
  skipped = 0
80
  for meta in files_with_paths:
81
- out_path = os.path.join(dest, meta["rel_path"])
82
- os.makedirs(os.path.dirname(out_path), exist_ok=True)
83
  if (
84
  meta["size"] > 0
85
- and os.path.exists(out_path)
86
- and os.path.getsize(out_path) == meta["size"]
87
  ):
88
  skipped += 1
89
  continue
90
- tasks.append((meta["id"], out_path))
91
 
92
  print(f"Skipping {skipped} existing files; {len(tasks)} to download.")
93
 
@@ -213,7 +211,7 @@ def split_test_train_val(args=None):
213
  try:
214
  if dst.exists() or dst.is_symlink():
215
  dst.unlink()
216
- os.symlink(src, dst)
217
  except FileExistsError:
218
  pass
219
  else: # copy
@@ -221,11 +219,11 @@ def split_test_train_val(args=None):
221
  dst.unlink()
222
  # use hardlink if possible to be fast and space efficient
223
  try:
224
- os.link(src, dst)
225
  except OSError:
226
  import shutil
227
 
228
- shutil.copy2(src, dst)
229
 
230
  for split_name, split_ids in (
231
  ("train", train_idx),
 
46
  }
47
  for file in drive.ListFile(params).GetList():
48
  if file["mimeType"] == "application/vnd.google-apps.folder":
49
+ sub_prefix = (f"{prefix}/{file['title']}" if prefix else file["title"])
 
 
50
  items += list_files_with_paths(drive, file["id"], sub_prefix)
51
  else:
52
+ rel_path = f"{prefix}/{file['title']}" if prefix else file["title"]
53
  size = int(file.get("fileSize", 0)) if "fileSize" in file else 0
54
  items.append(
55
  {
 
65
 
66
  def download_folder(folder_id, dest, service_account_json, workers: int):
67
  drive = authenticate(service_account_json)
68
+ Path(dest).mkdir(parents=True, exist_ok=True)
69
 
70
  print(f"Listing files in folder {folder_id}...")
71
  files_with_paths = list_files_with_paths(drive, folder_id)
 
76
  tasks = []
77
  skipped = 0
78
  for meta in files_with_paths:
79
+ out_path = Path(dest) / meta["rel_path"]
80
+ out_path.parent.mkdir(parents=True, exist_ok=True)
81
  if (
82
  meta["size"] > 0
83
+ and out_path.exists()
84
+ and out_path.stat().st_size == meta["size"]
85
  ):
86
  skipped += 1
87
  continue
88
+ tasks.append((meta["id"], str(out_path)))
89
 
90
  print(f"Skipping {skipped} existing files; {len(tasks)} to download.")
91
 
 
211
  try:
212
  if dst.exists() or dst.is_symlink():
213
  dst.unlink()
214
+ os.symlink(str(src), str(dst))
215
  except FileExistsError:
216
  pass
217
  else: # copy
 
219
  dst.unlink()
220
  # use hardlink if possible to be fast and space efficient
221
  try:
222
+ os.link(str(src), str(dst))
223
  except OSError:
224
  import shutil
225
 
226
+ shutil.copy2(str(src), str(dst))
227
 
228
  for split_name, split_ids in (
229
  ("train", train_idx),
scripts/trt_infer.py CHANGED
@@ -18,12 +18,13 @@ except Exception as e: # pragma: no cover
18
  ) from e
19
 
20
  import yaml
 
21
 
22
 
23
  # ---- Utility: TRT engine wrapper ----
24
  class TrtEngine:
25
  def __init__(self, engine_path: str):
26
- assert os.path.isfile(engine_path), f"Engine not found: {engine_path}"
27
  logger = trt.Logger(trt.Logger.ERROR)
28
  with open(engine_path, 'rb') as f, trt.Runtime(logger) as runtime:
29
  self.engine = runtime.deserialize_cuda_engine(f.read())
@@ -270,7 +271,7 @@ def infer_image_trt(
270
  save_prob: bool = False,
271
  prob_thresh: Optional[float] = None,
272
  ) -> Tuple[np.ndarray, np.ndarray]:
273
- assert os.path.isfile(img_path), f"Image not found: {img_path}"
274
  bgr = cv2.imread(img_path, cv2.IMREAD_COLOR)
275
  assert bgr is not None, f"Failed to read {img_path}"
276
  rgb = cv2.cvtColor(bgr, cv2.COLOR_BGR2RGB).astype(np.float32) / 255.0
@@ -301,13 +302,13 @@ def infer_image_trt(
301
  pred = (prob_f > prob_thresh).astype(np.uint8) * 255
302
 
303
  if out_dir is not None:
304
- os.makedirs(out_dir, exist_ok=True)
305
- stem = os.path.splitext(os.path.basename(img_path))[0]
306
- out_mask = os.path.join(out_dir, f"{stem}_pred.png")
307
- cv2.imwrite(out_mask, pred)
308
  if save_prob:
309
- out_prob = os.path.join(out_dir, f"{stem}_prob.npy")
310
- np.save(out_prob, prob_f.astype(np.float32))
311
 
312
  return pred, prob_f
313
 
@@ -341,7 +342,7 @@ def main():
341
 
342
  if args.benchmark:
343
  bench_dir = args.bench_images_dir or cfg["data"]["test_images"]
344
- assert os.path.isdir(bench_dir), f"Not a directory: {bench_dir}"
345
  size_filter: Optional[Tuple[int, int]] = None
346
  if args.bench_size_filter:
347
  try:
@@ -353,7 +354,7 @@ def main():
353
  )
354
  img_files = sorted(
355
  [
356
- os.path.join(bench_dir, p)
357
  for p in os.listdir(bench_dir)
358
  if p.lower().endswith((".jpg", ".jpeg"))
359
  ]
@@ -473,12 +474,12 @@ def main():
473
  return
474
 
475
  img_dir = args.images_dir
476
- assert os.path.isdir(img_dir)
477
- os.makedirs(args.out, exist_ok=True)
478
  img_files = sorted([p for p in os.listdir(img_dir) if p.lower().endswith((".jpg", ".jpeg"))])
479
  assert len(img_files) > 0
480
  for name in img_files:
481
- p = os.path.join(img_dir, name)
482
  infer_image_trt(coarse, fine, p, cfg, out_dir=args.out, save_prob=args.save_prob)
483
  print("[TRT][infer] Done.")
484
 
 
18
  ) from e
19
 
20
  import yaml
21
+ from pathlib import Path
22
 
23
 
24
  # ---- Utility: TRT engine wrapper ----
25
  class TrtEngine:
26
  def __init__(self, engine_path: str):
27
+ assert Path(engine_path).is_file(), f"Engine not found: {engine_path}"
28
  logger = trt.Logger(trt.Logger.ERROR)
29
  with open(engine_path, 'rb') as f, trt.Runtime(logger) as runtime:
30
  self.engine = runtime.deserialize_cuda_engine(f.read())
 
271
  save_prob: bool = False,
272
  prob_thresh: Optional[float] = None,
273
  ) -> Tuple[np.ndarray, np.ndarray]:
274
+ assert Path(img_path).is_file(), f"Image not found: {img_path}"
275
  bgr = cv2.imread(img_path, cv2.IMREAD_COLOR)
276
  assert bgr is not None, f"Failed to read {img_path}"
277
  rgb = cv2.cvtColor(bgr, cv2.COLOR_BGR2RGB).astype(np.float32) / 255.0
 
302
  pred = (prob_f > prob_thresh).astype(np.uint8) * 255
303
 
304
  if out_dir is not None:
305
+ Path(out_dir).mkdir(parents=True, exist_ok=True)
306
+ stem = Path(img_path).stem
307
+ out_mask = Path(out_dir) / f"{stem}_pred.png"
308
+ cv2.imwrite(str(out_mask), pred)
309
  if save_prob:
310
+ out_prob = Path(out_dir) / f"{stem}_prob.npy"
311
+ np.save(str(out_prob), prob_f.astype(np.float32))
312
 
313
  return pred, prob_f
314
 
 
342
 
343
  if args.benchmark:
344
  bench_dir = args.bench_images_dir or cfg["data"]["test_images"]
345
+ assert Path(bench_dir).is_dir(), f"Not a directory: {bench_dir}"
346
  size_filter: Optional[Tuple[int, int]] = None
347
  if args.bench_size_filter:
348
  try:
 
354
  )
355
  img_files = sorted(
356
  [
357
+ str(Path(bench_dir) / p)
358
  for p in os.listdir(bench_dir)
359
  if p.lower().endswith((".jpg", ".jpeg"))
360
  ]
 
474
  return
475
 
476
  img_dir = args.images_dir
477
+ assert Path(img_dir).is_dir()
478
+ Path(args.out).mkdir(parents=True, exist_ok=True)
479
  img_files = sorted([p for p in os.listdir(img_dir) if p.lower().endswith((".jpg", ".jpeg"))])
480
  assert len(img_files) > 0
481
  for name in img_files:
482
+ p = str(Path(img_dir) / name)
483
  infer_image_trt(coarse, fine, p, cfg, out_dir=args.out, save_prob=args.save_prob)
484
  print("[TRT][infer] Done.")
485
 
train.py CHANGED
@@ -24,6 +24,7 @@ from src.wireseghr.model.label_downsample import downsample_label_maxpool
24
  from src.wireseghr.data.sampler import BalancedPatchSampler
25
  from src.wireseghr.metrics import compute_metrics
26
  from infer import _coarse_forward, _tiled_fine_forward
 
27
 
28
 
29
  class SizeBatchSampler:
@@ -76,8 +77,8 @@ def main():
76
  args = parser.parse_args()
77
 
78
  cfg_path = args.config
79
- if not os.path.isabs(cfg_path):
80
- cfg_path = os.path.join(os.getcwd(), cfg_path)
81
 
82
  with open(cfg_path, "r") as f:
83
  cfg = yaml.safe_load(f)
@@ -200,7 +201,7 @@ def main():
200
  start_step = 0
201
  best_f1 = -1.0
202
  resume_path = cfg.get("resume", None)
203
- if resume_path and os.path.isfile(resume_path):
204
  print(f"[WireSegHR][train] Resuming from {resume_path}")
205
  start_step, best_f1 = _load_checkpoint(
206
  resume_path, model, optim, scaler, device
@@ -303,7 +304,7 @@ def main():
303
  if val_stats["f1"] > best_f1:
304
  best_f1 = val_stats["f1"]
305
  _save_checkpoint(
306
- os.path.join(out_dir, "best.pt"),
307
  step,
308
  model,
309
  optim,
@@ -313,7 +314,7 @@ def main():
313
  # Save periodic ckpt
314
  if ckpt_interval > 0 and (step % ckpt_interval == 0):
315
  _save_checkpoint(
316
- os.path.join(out_dir, f"ckpt_{step}.pt"),
317
  step,
318
  model,
319
  optim,
@@ -327,7 +328,7 @@ def main():
327
  dset_test,
328
  coarse_test,
329
  device,
330
- os.path.join(out_dir, f"test_vis_{step}"),
331
  amp_enabled,
332
  mm_enable,
333
  mm_kernel,
@@ -341,7 +342,7 @@ def main():
341
 
342
  # Save a final checkpoint upon completion
343
  _save_checkpoint(
344
- os.path.join(out_dir, f"ckpt_{iters}.pt"), step, model, optim, scaler, best_f1
345
  )
346
 
347
  # Final test evaluation
@@ -374,10 +375,10 @@ def main():
374
  f"[Test Final][Coarse] IoU={test_stats['iou_coarse']:.4f} F1={test_stats['f1_coarse']:.4f} P={test_stats['precision_coarse']:.4f} R={test_stats['recall_coarse']:.4f}"
375
  )
376
  # Save final evaluation artifacts
377
- final_out = os.path.join(out_dir, f"final_vis_{step}")
378
- os.makedirs(final_out, exist_ok=True)
379
  # Dump metrics for record
380
- with open(os.path.join(final_out, "metrics.yaml"), "w") as f:
381
  yaml.safe_dump({**test_stats, "step": step}, f, sort_keys=False)
382
  # Save predictions (fine + coarse) for the whole test set
383
  save_final_visuals(
@@ -385,7 +386,7 @@ def main():
385
  dset_test,
386
  coarse_test,
387
  device,
388
- final_out,
389
  amp_enabled,
390
  amp_dtype,
391
  prob_thresh,
@@ -615,7 +616,7 @@ def _save_checkpoint(
615
  scaler: GradScaler,
616
  best_f1: float,
617
  ):
618
- os.makedirs(os.path.dirname(path), exist_ok=True)
619
  state = {
620
  "step": step,
621
  "model": model.state_dict(),
@@ -765,7 +766,7 @@ def save_test_visuals(
765
  prob_thresh: float,
766
  max_samples: int = 8,
767
  ):
768
- os.makedirs(out_dir, exist_ok=True)
769
  for i in range(min(max_samples, len(dset_test))):
770
  item = dset_test[i]
771
  img = item["image"].astype(np.float32) / 255.0
@@ -783,8 +784,8 @@ def save_test_visuals(
783
  pred = ((prob_up > prob_thresh).to(torch.uint8) * 255).cpu().numpy()
784
  # Save input and prediction
785
  img_bgr = (img[..., ::-1] * 255.0).astype(np.uint8)
786
- cv2.imwrite(os.path.join(out_dir, f"{i:03d}_input.jpg"), img_bgr)
787
- cv2.imwrite(os.path.join(out_dir, f"{i:03d}_pred.png"), pred)
788
 
789
 
790
  @torch.no_grad()
@@ -803,7 +804,7 @@ def save_final_visuals(
803
  fine_overlap: int,
804
  fine_batch: int,
805
  ):
806
- os.makedirs(out_dir, exist_ok=True)
807
  for i in range(len(dset_test)):
808
  item = dset_test[i]
809
  img = item["image"].astype(np.float32) / 255.0
@@ -838,9 +839,9 @@ def save_final_visuals(
838
  # Save input and predictions
839
  img_bgr = (img[..., ::-1] * 255.0).astype(np.uint8)
840
  base = f"{i:03d}"
841
- cv2.imwrite(os.path.join(out_dir, f"{base}_input.jpg"), img_bgr)
842
- cv2.imwrite(os.path.join(out_dir, f"{base}_coarse_pred.png"), pred_coarse)
843
- cv2.imwrite(os.path.join(out_dir, f"{base}_fine_pred.png"), pred_fine)
844
 
845
 
846
  if __name__ == "__main__":
 
24
  from src.wireseghr.data.sampler import BalancedPatchSampler
25
  from src.wireseghr.metrics import compute_metrics
26
  from infer import _coarse_forward, _tiled_fine_forward
27
+ from pathlib import Path
28
 
29
 
30
  class SizeBatchSampler:
 
77
  args = parser.parse_args()
78
 
79
  cfg_path = args.config
80
+ if not Path(cfg_path).is_absolute():
81
+ cfg_path = str(Path.cwd() / cfg_path)
82
 
83
  with open(cfg_path, "r") as f:
84
  cfg = yaml.safe_load(f)
 
201
  start_step = 0
202
  best_f1 = -1.0
203
  resume_path = cfg.get("resume", None)
204
+ if resume_path and Path(resume_path).is_file():
205
  print(f"[WireSegHR][train] Resuming from {resume_path}")
206
  start_step, best_f1 = _load_checkpoint(
207
  resume_path, model, optim, scaler, device
 
304
  if val_stats["f1"] > best_f1:
305
  best_f1 = val_stats["f1"]
306
  _save_checkpoint(
307
+ str(Path(out_dir) / "best.pt"),
308
  step,
309
  model,
310
  optim,
 
314
  # Save periodic ckpt
315
  if ckpt_interval > 0 and (step % ckpt_interval == 0):
316
  _save_checkpoint(
317
+ str(Path(out_dir) / f"ckpt_{step}.pt"),
318
  step,
319
  model,
320
  optim,
 
328
  dset_test,
329
  coarse_test,
330
  device,
331
+ str(Path(out_dir) / f"test_vis_{step}"),
332
  amp_enabled,
333
  mm_enable,
334
  mm_kernel,
 
342
 
343
  # Save a final checkpoint upon completion
344
  _save_checkpoint(
345
+ str(Path(out_dir) / f"ckpt_{iters}.pt"), step, model, optim, scaler, best_f1
346
  )
347
 
348
  # Final test evaluation
 
375
  f"[Test Final][Coarse] IoU={test_stats['iou_coarse']:.4f} F1={test_stats['f1_coarse']:.4f} P={test_stats['precision_coarse']:.4f} R={test_stats['recall_coarse']:.4f}"
376
  )
377
  # Save final evaluation artifacts
378
+ final_out = Path(out_dir) / f"final_vis_{step}"
379
+ final_out.mkdir(parents=True, exist_ok=True)
380
  # Dump metrics for record
381
+ with open(final_out / "metrics.yaml", "w") as f:
382
  yaml.safe_dump({**test_stats, "step": step}, f, sort_keys=False)
383
  # Save predictions (fine + coarse) for the whole test set
384
  save_final_visuals(
 
386
  dset_test,
387
  coarse_test,
388
  device,
389
+ str(final_out),
390
  amp_enabled,
391
  amp_dtype,
392
  prob_thresh,
 
616
  scaler: GradScaler,
617
  best_f1: float,
618
  ):
619
+ Path(path).parent.mkdir(parents=True, exist_ok=True)
620
  state = {
621
  "step": step,
622
  "model": model.state_dict(),
 
766
  prob_thresh: float,
767
  max_samples: int = 8,
768
  ):
769
+ Path(out_dir).mkdir(parents=True, exist_ok=True)
770
  for i in range(min(max_samples, len(dset_test))):
771
  item = dset_test[i]
772
  img = item["image"].astype(np.float32) / 255.0
 
784
  pred = ((prob_up > prob_thresh).to(torch.uint8) * 255).cpu().numpy()
785
  # Save input and prediction
786
  img_bgr = (img[..., ::-1] * 255.0).astype(np.uint8)
787
+ cv2.imwrite(str(Path(out_dir) / f"{i:03d}_input.jpg"), img_bgr)
788
+ cv2.imwrite(str(Path(out_dir) / f"{i:03d}_pred.png"), pred)
789
 
790
 
791
  @torch.no_grad()
 
804
  fine_overlap: int,
805
  fine_batch: int,
806
  ):
807
+ Path(out_dir).mkdir(parents=True, exist_ok=True)
808
  for i in range(len(dset_test)):
809
  item = dset_test[i]
810
  img = item["image"].astype(np.float32) / 255.0
 
839
  # Save input and predictions
840
  img_bgr = (img[..., ::-1] * 255.0).astype(np.uint8)
841
  base = f"{i:03d}"
842
+ cv2.imwrite(str(Path(out_dir) / f"{base}_input.jpg"), img_bgr)
843
+ cv2.imwrite(str(Path(out_dir) / f"{base}_coarse_pred.png"), pred_coarse)
844
+ cv2.imwrite(str(Path(out_dir) / f"{base}_fine_pred.png"), pred_fine)
845
 
846
 
847
  if __name__ == "__main__":