Sudabaka commited on
Commit
c7aa71c
·
verified ·
1 Parent(s): abd586c

chore: 同步最新实现代码(FP16 导出 / 轻量教师入口)与更新后的训练素材清单

Browse files
Files changed (1) hide show
  1. code/teacher_run.py +44 -0
code/teacher_run.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """教师打标的轻量入口:只做目录扫描与 SfdpTeacher 调用,不加载 torch / cv2。
3
+
4
+ 避免与训练同时启动时因 torch DLL 占用内存触发 WinError 1455(页面文件太小)。
5
+ """
6
+ import os
7
+ import subprocess
8
+ import sys
9
+
10
+ TILES = r"D:\sfdp-ai\siamese\data\tiles"
11
+ LABELS = r"D:\sfdp-ai\siamese\data\labels"
12
+ TEACHER = r"D:\sfdp-ai\bin\SfdpTeacher.exe"
13
+
14
+
15
+ def main():
16
+ os.makedirs(LABELS, exist_ok=True)
17
+ print("SCAN_START", TILES, flush=True)
18
+ dirs = sorted(d for d in os.listdir(TILES) if os.path.isdir(os.path.join(TILES, d)))
19
+ print("SCAN_DIRS", len(dirs), flush=True)
20
+
21
+ todo = []
22
+ for i, d in enumerate(dirs):
23
+ if not os.path.exists(os.path.join(LABELS, d + ".csv")):
24
+ todo.append(d)
25
+ if (i + 1) % 2000 == 0:
26
+ print("SCAN", i + 1, "/", len(dirs), flush=True)
27
+ print("DIRS", len(dirs), "TODO", len(todo), flush=True)
28
+
29
+ for i, d in enumerate(todo):
30
+ try:
31
+ subprocess.run(
32
+ [TEACHER, os.path.join(TILES, d), os.path.join(LABELS, d + ".csv"),
33
+ "--mode", "uhd", "--crop", "128", "--per-pair", "4", "--limit", "0"],
34
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=300,
35
+ )
36
+ except Exception as e:
37
+ print("SKIP", d, repr(e), flush=True)
38
+ if (i + 1) % 10 == 0:
39
+ print("PROGRESS", i + 1, "/", len(todo), flush=True)
40
+ print("DONE", flush=True)
41
+
42
+
43
+ if __name__ == "__main__":
44
+ main()