SFDP-Siamese-NET-AI / code /teacher_run.py
Sudabaka's picture
chore: 同步最新实现代码(FP16 导出 / 轻量教师入口)与更新后的训练素材清单
c7aa71c verified
Raw History Blame Contribute Delete
1.56 kB
# -*- coding: utf-8 -*-
"""教师打标的轻量入口:只做目录扫描与 SfdpTeacher 调用,不加载 torch / cv2。
避免与训练同时启动时因 torch DLL 占用内存触发 WinError 1455(页面文件太小)。
"""
import os
import subprocess
import sys
TILES = r"D:\sfdp-ai\siamese\data\tiles"
LABELS = r"D:\sfdp-ai\siamese\data\labels"
TEACHER = r"D:\sfdp-ai\bin\SfdpTeacher.exe"
def main():
os.makedirs(LABELS, exist_ok=True)
print("SCAN_START", TILES, flush=True)
dirs = sorted(d for d in os.listdir(TILES) if os.path.isdir(os.path.join(TILES, d)))
print("SCAN_DIRS", len(dirs), flush=True)
todo = []
for i, d in enumerate(dirs):
if not os.path.exists(os.path.join(LABELS, d + ".csv")):
todo.append(d)
if (i + 1) % 2000 == 0:
print("SCAN", i + 1, "/", len(dirs), flush=True)
print("DIRS", len(dirs), "TODO", len(todo), flush=True)
for i, d in enumerate(todo):
try:
subprocess.run(
[TEACHER, os.path.join(TILES, d), os.path.join(LABELS, d + ".csv"),
"--mode", "uhd", "--crop", "128", "--per-pair", "4", "--limit", "0"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=300,
)
except Exception as e:
print("SKIP", d, repr(e), flush=True)
if (i + 1) % 10 == 0:
print("PROGRESS", i + 1, "/", len(todo), flush=True)
print("DONE", flush=True)
if __name__ == "__main__":
main()