ci / smoke (push) Canceled after 0s
- config.yaml canonical for stream/models/counting/batch/output/camera - models.modes hold engines+class filters only; conf/iou/min_bbox in detection_params - predict.py derives tracker roles structurally (no per-mode branching) - dashboard mode switch validates + persists atomically to config.yaml - .env keeps secrets/deployment only; zones.json geometry; tracker.yaml hyperparams - batch_mode.json keeps manual/auto batch mode; legacy model_mode ignored w/ warning - src/detection+tracking gain iou param (default 0.7 = no behavior change)
4.5 KiB
4.5 KiB
AGENTS.md — karung (sack counter)
Repo: https://git.proit.id/andrew/karung-counting-feedmill-semarang (transferred from ervan/; old remote redirects, but git remote set-url origin to the new URL).
AI video analytics (Jetson) counting feed sacks loaded onto trucks. UI/log strings are
Indonesian (karung=sack, truk=truck); YOLO class names are English
(sack, box, truck, person). Details: README.md, docs/.
Which pipeline to touch
predict.py= production AND dev CLI (runs askarung-counter.servicewith zero args). Dev flags:--source VID --env .env --config YAML --model X --output-dir D --output-json F --sack-conf C --truck-conf C --box-conf C --box-model P --model-mode M --batch-timeout S --max-frames N --no-dashboard --no-db. Zero flags = systemd behaviour (config.yaml+.env). Model modes are DATA inconfig.yamlmodels.modes(engines + class filters only; conf/iou/min_bbox inmodels.detection_params): A=combined only; B=v4 truck + yolo11n sack+box; C=A + yolo11n box-only (default); D=v4 truck + best sack-only + yolo11n box-only. New modes need no code change. All modes load.enginefiles (2-3 coexist, ~24 MB peak); never mix load order assumptions — PyTorch.ptmust load before TensorRT.engine.src/= shared library (detection/tracking/counting/batch).python -m src.mainstill works but prints a deprecation pointer topredict.py.archive/= retired experiments (predict_new.py,rpo_iki/,simple_predict.py, check/merge/test scripts). Git history preserved viagit mv. Don't resurrect without asking.
Gotchas
- Unified config:
config.yamlis canonical (stream/models/counting/batch/ output/camera viasrc/config_loader.py);.envholds secrets + deployment only (RTSP_URL, dashboard host/ports/secret/site);zones.jsonholds geometry (polygons + left/right limits — knob keys there are ignored, warned);cfg/tracker.yamlholds tracker hyperparams.src/config.py(v3 keys likeLOCAL_RTSP) is deprecated — don't add keys there. Dashboard mode switches writeconfig.yamlmodels.active_mode(atomic, manual restart to apply);batch_mode.jsonkeeps only manual/auto batch mode. - Counting filters by class name, not ID:
SackDetector/BoxDetector/TruckDetectorfilter viaBaseDetector(class_filter)(src/detection.py); tracker keeps("sack", "truck", "box")(src/tracking.py); counting usesMultiClassLineCounter= dualLineCrossCounters on one shared line (src/counting.py). Same line geometry + 30px dedup for sacks and boxes. - All weights live in
models/(.pt/.onnxtracked;.enginegitignored — rebuild viaexport_model.py; per-mode detector/filter matrix inmodels/modelREADME.md). Verified classes:truck-detector={truck},model_karung_truk/v4-best={sack,truck},karung-dimuat-*-seg-200e= {person,sack} (seg; persons drawn, never counted),best={sack},yolo11n-…-sack+box={sack,box}.predict.pyauto-picksMODEL_PATHenv, elsemodels/v4-best.engine>.pt>v4-best (1).pt>models/model_karung_truk.*.src/config.pydefaults:models/best.engine(sack) /models/truck-detector.engine. - Counting trigger is the bbox top edge (y1) vs a truck-anchored line band
(
src/counting.py,src/truck_roi.py); truck detect runs every 15th frame only. - Tests:
python -m pytest tests/ -q(smoke tests forcounting,batch,config— pure-Python, no cv2/ultralytics needed). CI (.github/workflows/ci.yml) installs onlynumpy python-dotenv pytest+ runs pytest +compileall. Deps:requirements.txt(unpinned; never pip-install torch from PyPI on the Jetson — use the NVIDIA wheels already on device). For visual checks run on a video file (--source), not the live RTSP. - Don't commit state:
.gitignoreexcludes*.engine(rebuildable),*.mp4/*.jpg/*.png,*.db,.env,batch_history_folder/. Videos and local DBs already sit untracked in the working tree — leave them alone.
Deploy (Jetson 192.168.192.96, user jetson)
deploy_to_jetson.pysyncspredict.py,counter_dashboard.py,templates/{operator,monitoring,base}.html,.env, plusmodels/*.engine(skips missing local files; creates remotemodels/)..pt/.onnxstay local. Edits elsewhere (e.g.src/,zones.json) need manual sync.- Services:
karung-counter(predict.py),karung-counter-dashboard(counter_dashboard.py, ports 5000/5721). TensorRT export:python export_model.py models/<name>.pt— run on the Jetson.