Files
karung-counting-feedmill-se…/AGENTS.md
T

3.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 as karung-counter.service with zero args). Dev flags: --source VID --env .env --model X --output-dir D --output-json F --sack-conf C --truck-conf C --box-conf C(placeholder, unused) --batch-timeout S --max-frames N --no-dashboard --no-db. Zero flags = systemd behaviour. Combined sack+truck model + src/ modules, shapely zones, SQLite, live-frame publish.
  • src/ = shared library (detection/tracking/counting/batch). python -m src.main still works but prints a deprecation pointer to predict.py.
  • archive/ = retired experiments (predict_new.py, rpo_iki/, simple_predict.py, check/merge/test scripts). Git history preserved via git mv. Don't resurrect without asking.

Gotchas

  • Two env-key dialects: production .env uses RTSP_URL, DB_PATH, MODEL_PATH, … (predict.py, counter_dashboard.py); src/config.py reads different keys (LOCAL_RTSP, MODEL_SACK_PATH, MODEL_TRUCK_PATH, …). Check which loader your entry point uses before adding config.
  • Counting filters by class name, not ID: SackDetector keeps name == "sack" only (src/detection.py); tracker keeps ("sack", "truck") (src/tracking.py). The new yolo11n-bbox-100ep-sack+box-*.pt has a box class that nothing consumes yet — adding box support means extending those allow-lists plus counter semantics.
  • Verified checkpoint classes: truck-detector={truck}, model_karung_truk/v4-best= {sack,truck}, karung-dimuat-*-seg-200e={person,sack} (seg; persons drawn, never counted), best={sack}. predict.py auto-picks MODEL_PATH env, else model_karung_truk.engine > .pt > v4-best.pt.
  • 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 for counting, batch, config — pure-Python, no cv2/ultralytics needed). CI (.github/workflows/ci.yml) installs only numpy 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 binaries/state: .gitignore excludes *.pt/*.onnx/*.engine, *.mp4/*.jpg/*.png, *.db, .env, batch_history_folder/. Large weights and videos already sit untracked in the working tree — leave them alone.

Deploy (Jetson 192.168.192.96, user jetson)

  • deploy_to_jetson.py syncs only predict.py, counter_dashboard.py, templates/{operator,monitoring,base}.html, .env, then restarts services. 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: export_model.py (export_v4.py variant) — run on the Jetson, then repoint the loader at .engine.