仓库结构: edge/ 设备端(原根目录设备端代码整体移入) control/ 管理端(清理后) docs/ 文档(PRD 移入 design/) README.md 根导航(新增) 清理: - control/.brainstorm 临时草稿删除 - control 根级重复文档(API表/PRD_04)并入 docs/design/ - control/plan.md -> docs/implementation/control-plan.md - control/safesightd-linux-arm64 二进制取消版本控制(.gitignore) - edge/transform 模型转换产物归入 models/,onnx/pt 大源文件取消跟踪(.gitignore) - Readme.md(PRD) -> docs/design/PRD_Product_v1.2.md(避开 README 大小写冲突) 更新: - 根 README.md 导航、docs/README.md 文档索引 - deployment.md/检查表路径加 edge/ 前缀 - .gitignore 重写(edge/control 分区规则)
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Test RetinaFace RKNN model directly"""
|
|
|
|
import numpy as np
|
|
from PIL import Image
|
|
from rknn.api import RKNN
|
|
|
|
# Create dummy test image (simulating a face region)
|
|
test_img = np.random.randint(0, 255, (320, 320, 3), dtype=np.uint8)
|
|
# Add a rectangle to simulate face
|
|
test_img[100:220, 100:220] = 200 # lighter region
|
|
|
|
# Save test image
|
|
Image.fromarray(test_img).save('test_input.jpg')
|
|
print("Created test image")
|
|
|
|
# Load and test RKNN model
|
|
rknn = RKNN(verbose=False)
|
|
print("Loading RKNN model...")
|
|
ret = rknn.load_rknn('face_det_retinaface_mobile320_rk3588.rknn')
|
|
if ret != 0:
|
|
print("Failed to load model")
|
|
exit(1)
|
|
|
|
print("Initializing runtime...")
|
|
ret = rknn.init_runtime(target='rk3588')
|
|
if ret != 0:
|
|
print("Failed to init runtime")
|
|
exit(1)
|
|
|
|
# Prepare input (NHWC -> NCHW)
|
|
input_data = np.expand_dims(test_img, 0) # Add batch dimension
|
|
print(f"Input shape: {input_data.shape}, dtype: {input_data.dtype}")
|
|
|
|
# Inference
|
|
print("Running inference...")
|
|
outputs = rknn.inference(inputs=[input_data])
|
|
print(f"Output count: {len(outputs)}")
|
|
for i, out in enumerate(outputs):
|
|
print(f"Output {i}: shape={out.shape}, min={out.min():.4f}, max={out.max():.4f}")
|
|
|
|
rknn.release()
|
|
print("Done!")
|