Imported from xingxinonline/SmallModels (
AGENTS.md). Install upstream withnpx skills add xingxinonline/SmallModels. Copyright stays with the author.
Project Context for AI Agents
This repository contains the recommended AI models, architecture analysis, and deployment guides for the S300 Chip (NPU/DSP/MCU).
ð Documentation Structure
- README.md: Project overview, hardware specifications (NPU/DSP/MCU), and the list of deployable open-source models. Start here for general context.
- ARCHITECTURE.md: Technical deep dive, including architecture analysis (WebRTC vs Native), performance benchmarking, model validation protocols, and end-to-end system testing.
ð€ Hardware Constraints (Critical for Code Generation)
When generating code or suggesting models for this project, ALWAYS keep the following S300 hardware constraints in mind:
- NPU (Neural Processing Unit):
- Precision: Int8 / Int16 only. No Float32 support in NPU.
- Operators: Conv2D (Kernel <= 7x7), Pooling (Kernel <= 15), ReLU/Leaky-ReLU/Softmax.
- Unsupported: Complex dynamic control flow, large kernels (>7x7), some advanced activations (e.g., GELU, Swish need approximation).
- DSP (SensPro 250):
- Best for: Audio pre-processing (AEC, AGC, VAD), FFT, Sensor Fusion.
- Libraries: CEVA ClearVox, CMSIS-DSP.
- MCU (Cortex-M4):
- Best for: System control, peripheral management, lightweight business logic.
- Avoid heavy computation here.
ð ïž Development Guidelines
Python Environment (UV)
We use uv for fast Python package management.
- Install:
pip install uv - Sync:
uv pip sync requirements.txt - Add Package:
uv add <package>
Git Commit Convention
Follow the Conventional Commits format:
<type>(<scope>): <short description>
WHAT: ...
WHY: ...
HOW: ...
- Types:
feat,fix,docs,style,refactor,perf,test,build,ci,chore,revert. - Scopes:
npu,dsp,mcu,audio,vision,test,docs,gesture,recognizer,matching.
Git Commit Splitting (æåæäº€è§è) â
åœäžæ¬¡åŒåæ¶åå€äžªç¬ç«åèœæ¶ïŒå¿ é¡»æåæäº€ïŒ
- æåèœæš¡åæåïŒæ¯äžªç¬ç«çåèœç¹äžäžªæäº€
- ææä»¶ç±»åæåïŒä»£ç ãææ¡£ãæµè¯ååŒæäº€
- ä¿ææäº€ååæ§ïŒæ¯äžªæäº€åºè¯¥æ¯å¯ç¬ç«çè§£ç宿ŽåæŽ
æå瀺äŸïŒ
# é误ïŒäžäžªå€§æäº€å
å«æææ¹åš
git commit -m "feat: å®æç®æ è·éäŒå"
# æ£ç¡®ïŒæåèœæå
git commit -m "feat(gesture): æå¿æ£æµåšäŒå - 鿩忿æå¿çæ"
git commit -m "refactor(recognizer): å€è§è§è¯å«åšæ¹è¿ - è§è§åºç®¡ççç¥"
git commit -m "feat(matching): åå±å¹é
çç¥ - åºäºäººèžèŽšéå级"
git commit -m "docs: æŽæ°æ¹æ¡Då¯åšé»èŸåå¹é
çç¥ææ¡£"
æåååïŒ
- â äžäžªåèœç¹ = äžäžªæäº€
- â çžå ³ç代ç +æµè¯å¯ä»¥æŸäžèµ·
- â ææ¡£æŽæ°åç¬æäº€
- â äžèŠæäžçžå ³çæ¹åšæ··åšäžèµ·
- â äžèŠäžºäº"å¹²å"è squash ææä¹çåå²
ð Task Instructions
- If asked to recommend a model, check
README.mdfirst. - If asked about testing or validation, refer to
ARCHITECTURE.md. - If asked to write code, ensure it is compatible with the S300 constraints (e.g., use quantization-aware training, avoid unsupported ops).
ð» Local PC Environment (Pre-validation)
Before porting to the S300 chip, models will be validated on the local PC to verify logic and performance baselines.
- OS: Windows 11 Pro (10.0.22631)
- CPU: Intel Core i7-12700KF (12 Cores, 20 Threads)
- RAM: 32 GB
- GPU: NVIDIA GeForce RTX 3070 Ti
- Goal: Run FP32/Int8 models locally to check functional correctness and simulate NPU constraints (e.g., using TFLite interpreter with Int8 delegates).
ð Development Workflow (åŒåæµçš)
When implementing a new feature or model validation, follow this complete workflow:
1. Architecture Design (æ¶æè®Ÿè®¡)
- Define system modules and their responsibilities
- Draw data flow diagrams
- Specify interfaces between components
- Document in
examples/<feature>/README.md
2. Code Implementation (代ç å®ç°)
- Create modular, reusable code structure
- Follow Python best practices (type hints, docstrings)
- Separate concerns: config, capture, inference, visualization
3. Dependency Verification (äŸèµéªè¯)
# Install dependencies using uv
uv add <package_name>
# Verify installation
uv run python -c "import <package>; print(<package>.__version__)"
4. Compile Verification (çŒè¯éªè¯)
# Check for syntax errors
uv run python -m py_compile <file.py>
# Or use IDE's built-in linting
5. Execution Testing (æ§è¡æµè¯)
# Run the application
uv run python <main_script.py>
5.1 Interactive Testing with Background Processes (亀äºåŒåå°æµè¯)
â ïž CRITICAL: When running interactive applications (camera, GUI, gesture control, etc.):
-
Do NOT use
isBackground=truefor tests requiring user interaction- Background mode cannot capture user input or show real-time output
- Agent will not receive test results automatically
-
Correct approach for interactive tests:
# Run in foreground (isBackground=false) uv run python <interactive_script.py> -
If background mode is necessary:
- Wait sufficient time for user to complete testing
- Use
get_terminal_outputto actively check results - Do NOT assume test passed without checking output
- Agent MUST call
get_terminal_outputafter reasonable wait time (5-10 seconds)
-
Debug logging best practice:
- Add debug logs for state transitions and key events
- Use conditional debug flags:
process_gesture(..., debug=True) - Print logs in a parseable format for automated analysis
Example - Wrong approach:
# â Wrong: Start background process and immediately ask user for results
run_in_terminal(command, isBackground=true)
# Then ask user: "请åè¯æç»æ"
Example - Correct approach:
# â
Correct: Start background process, wait, then check output
run_in_terminal(command, isBackground=true)
# Wait for user to interact...
get_terminal_output(terminal_id) # Agent actively fetches results
# Analyze output and provide feedback
6. Documentation Update (ææ¡£æŽæ°)
- Update
AGENTS.mdwith new workflow requirements - Update
README.mdif new models are added - Create example-specific documentation
ð Examples Directory Structure
examples/
âââ face_detection/ # äººèžæ£æµç€ºäŸ
â âââ README.md # æ¶æè®Ÿè®¡ææ¡£
â âââ config.py # é
çœ®åæ°
â âââ camera.py # æå倎éé
â âââ detector.py # SCRFD æ£æµåš
â âââ visualizer.py # å¯è§åæš¡å
â âââ download_model.py # æš¡åäžèœœ
â âââ main.py # äž»çšåºå
¥å£
â âââ models/ # æš¡åæä»¶
âââ target_following/ # ç®æ è·éç€ºäŸ (æå¿æ§å¶)
â âââ README.md # æ¶æè®Ÿè®¡ææ¡£
â âââ config.py # é
çœ®åæ°äžç¶ææäžŸ
â âââ main.py # äž»çšåºå
¥å£
â âââ core/ # æ žå¿æš¡å
â â âââ camera.py # æå倎éé
â â âââ state_machine.py # ç¶ææºæ§å¶åš
â âââ detectors/ # æ£æµåšæš¡å
â â âââ gesture_detector.py # æå¿æ£æµ (MediaPipe)
â â âââ face_detector.py # äººèžæ£æµ (SCRFD)
â â âââ face_recognizer.py # 人èžè¯å« (ArcFace)
â â âââ person_detector.py # äººäœæ£æµ (YOLOv8-pose)
â âââ trackers/ # è·èžªæš¡å
â â âââ target_tracker.py # ç®æ è·èžªåš
â âââ visualizers/ # å¯è§åæš¡å
â â âââ visualizer.py # ç»æç»å¶
â âââ tests/ # åå
æµè¯
â â âââ test_gesture.py # æå¿æ£æµæµè¯
â â âââ test_face.py # 人èžè¯å«æµè¯
â â âââ test_person.py # äººäœæ£æµæµè¯
â âââ models/ # æš¡åæä»¶
â âââ scrfd_500m_bnkps.onnx # äººèžæ£æµ
â âââ w600k_r50.onnx # 人èžè¯å«
â âââ yolov8n-pose.onnx # 人äœå§¿æ
âââ <future_examples>/ # æŽå€ç€ºäŸ...
ð¯ Example: Face Detection Workflow
# 1. Navigate to example directory
cd examples/face_detection
# 2. Download model
uv run python download_model.py
# 3. Run face detection with camera
uv run python main.py
# Controls:
# - Press 'q' to quit
# - Press 's' to save screenshot
ð¯ Example: Target Following Workflow
# 1. Navigate to example directory
cd examples/target_following
# 2. Run individual tests first (recommended)
uv run python tests/test_gesture.py # Test gesture detection
uv run python tests/test_face.py # Test face recognition
uv run python tests/test_person.py # Test person detection
# 3. Run integrated target following
uv run python main.py
# Gesture Controls:
# - Open Palm (åŒ åŒææ): Start tracking - locks current face as target
# - Closed Fist (æ¡æ³): Stop tracking - returns to idle state
# - Press 'q' to quit
# State Machine:
# IDLE â (Open Palm) â TRACKING â (Closed Fist) â IDLE
# â
# LOST_TARGET (if target lost, waits for re-detection)