Initial public project cleanup
This commit is contained in:
commit
2034b04519
95 files changed
+16583
No files matched your search
@@ -0,0 +1,102 @@
|
||||
"""
|
||||
FINN部署产物检查工具
|
||||
|
||||
在FINN构建完成后运行,确认PYNQ部署所需文件是否齐全。
|
||||
"""
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def configure_stdio():
|
||||
"""Avoid console encoding failures when run from Windows terminals."""
|
||||
for stream in (sys.stdout, sys.stderr):
|
||||
if hasattr(stream, "reconfigure"):
|
||||
stream.reconfigure(encoding="utf-8", errors="replace")
|
||||
|
||||
|
||||
configure_stdio()
|
||||
|
||||
|
||||
def find_one(output_dir, patterns):
|
||||
for pattern in patterns:
|
||||
matches = sorted(output_dir.rglob(pattern))
|
||||
if matches:
|
||||
return matches[0]
|
||||
return None
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="检查FINN PYNQ部署产物")
|
||||
parser.add_argument("--output", default="output", help="FINN输出目录")
|
||||
parser.add_argument("--test_dir", default="../data/processed/val", help="验证集目录")
|
||||
args = parser.parse_args()
|
||||
|
||||
script_dir = Path(__file__).resolve().parent
|
||||
output_dir = Path(args.output)
|
||||
if not output_dir.is_absolute():
|
||||
output_dir = script_dir / output_dir
|
||||
output_dir = output_dir.resolve()
|
||||
|
||||
test_dir = Path(args.test_dir)
|
||||
if not test_dir.is_absolute():
|
||||
test_dir = (script_dir / test_dir).resolve()
|
||||
|
||||
print("=" * 60)
|
||||
print("FINN部署产物检查")
|
||||
print("=" * 60)
|
||||
print(f"输出目录: {output_dir}")
|
||||
|
||||
required = {
|
||||
"bitstream": find_one(output_dir, ["*.bit"]),
|
||||
"hwh": find_one(output_dir, ["*.hwh"]),
|
||||
"driver": find_one(output_dir, ["driver.py"]),
|
||||
}
|
||||
|
||||
ok = True
|
||||
for name, path in required.items():
|
||||
if path is None:
|
||||
print(f"✗ 缺少{name}")
|
||||
ok = False
|
||||
else:
|
||||
size_mb = path.stat().st_size / (1024 * 1024)
|
||||
print(f"✓ {name}: {path} ({size_mb:.2f} MB)")
|
||||
|
||||
runtime_weights = find_one(output_dir, ["runtime_weights"])
|
||||
if runtime_weights is not None:
|
||||
print(f"✓ runtime_weights: {runtime_weights}")
|
||||
else:
|
||||
print("ℹ 未发现runtime_weights目录;部分FINN设计不需要运行时权重")
|
||||
|
||||
if test_dir.exists():
|
||||
images = [
|
||||
path for path in test_dir.rglob("*")
|
||||
if path.suffix.lower() in {".jpg", ".jpeg", ".png"}
|
||||
]
|
||||
print(f"✓ 验证集图像: {len(images)} 张")
|
||||
else:
|
||||
print(f"✗ 验证集目录不存在: {test_dir}")
|
||||
ok = False
|
||||
|
||||
print("\nPYNQ传输命令模板:")
|
||||
print(" scp <bitfile> xilinx@192.168.2.99:~/finn_design.bit")
|
||||
print(" scp <hwh> xilinx@192.168.2.99:~/finn_design.hwh")
|
||||
print(" scp <driver.py> xilinx@192.168.2.99:~/driver.py")
|
||||
print(" scp pynq_test.py xilinx@192.168.2.99:~/")
|
||||
print(" scp -r ../data/processed/val xilinx@192.168.2.99:~/test_images")
|
||||
|
||||
print("\n板端测试命令:")
|
||||
print(" python3 -c \"import pynq; print(pynq.__version__)\"")
|
||||
print(" python3 pynq_test.py --test_dir test_images --test_image test_images/class_0/10.jpg --runs 100")
|
||||
|
||||
print("=" * 60)
|
||||
if ok:
|
||||
print("✓ 产物检查通过")
|
||||
return 0
|
||||
print("✗ 产物检查未通过")
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user