104 Commits
Author SHA1 Message Date
andrew 2fcd19b2a0 update full cycle parquet data and model, resulting 97,39% 2026-11-03 12:15:46 +07:00
andrew 2db4405556 keep output consistent and complete each day 2026-10-29 10:23:58 +07:00
andrew 902aa75dc8 Merge branch 'feat/integrate-weighing-system' into main 2026-10-21 08:41:52 +07:00
andrew 0fa77dcd6b ensure all file pushed 2026-10-20 16:33:36 +07:00
andrew c58b74b387 integrating chicken count, weighing, dashboard - fix 2026-10-20 16:10:37 +07:00
andrew 631b3ea1da feat(weighing): integrate hybrid allometric-RF weight model into counting repo
- growth_model.py: load best_weight_model.pkl (hybrid_allometric_rf) with local chicken-weighing/ path first, external as fallback
- aggregation.py: pass minor/major axis medians into predict_chicken_weight
- run_daily_weighing.sh: run local chicken-weighing/weighing_inference.py
- vendor chicken-weighing/ mirror (models, db, services, dashboard)
- configs: stage boundaries 0-14 early / 15+ mid; floor_config extends simulation_experiment
- services: fix paths to Project_FOLDER/.Codes
- requirements: add scikit-learn, lightgbm, pytest
- docs: sync README/RUN/API/ERD/CHANGELOG/CENTRAL_DASHBOARD to current code state
2026-10-20 15:54:31 +07:00
andrew ed0c64aa0e fix(db): checkpoint WAL so c09a76d purge actually lands in committed file
c09a76d's DELETE lived only in gitignored chicken_counts.db-wal; the
committed blob still had the 5 K2-L1 day-138 rows. PRAGMA
wal_checkpoint(TRUNCATE) applied; standalone file now 469 rows, 0 with
cycle_day>=100. Also moved host run dir
../VIDEOS/cycle7/K2/L1/2026-10-07 (day-138 predictions_*.parquet fed
dashboard weight trend) to /tmp/opencode/k2l1-purged/.
2026-10-12 09:58:39 +07:00
andrew c09a76db27 fix(weight): disable GBM at call site, purge K2-L1 day-138 rows
- use_gbm=True (f99fec9) activated step-function joblib: predicted
  weight constant per cycle-day band (215.6g days 9-11 across all
  cameras regardless of area). Revert to False per growth_model.py
  TODO: retrain with real morphometry + features_dict before re-enable.
- Delete 5 batch_runs rows location=K2-L1 date=2026-10-07 cycle_day=138
  (one-off manual run with stale cycle_start 2026-05-22; Gompertz
  baseline 4649g polluted trend). Backup: db/*.bak-before-k2purge-*.
2026-10-12 09:42:34 +07:00
andrew eeb1a3a96d fix(config): restore K1-L1 location label, add troubleshooting report 2026-10-12 08:31:33 +07:00
andrew 5286db026b fix(dashboard): auto-reconnect sqlite connection on db inode change 2026-10-12 08:31:33 +07:00
andrew e0b6b83d1d fix: isolate SIM location and pin absolute footage root 2026-10-09 17:09:35 +07:00
andrew f99fec97fb feat(weight): enable GBM at aggregation call site and update weight tests 2026-10-09 15:08:23 +07:00
andrew f56f564978 refactor(config): defer count task to defaults/cameras/stage, drop dead weighing keys 2026-10-09 14:59:48 +07:00
andrew 2f77822cdf fix(gate3): refresh started_at on job upsert, default status FAILED
- upsert now updates started_at so reruns keep self-consistent rows
  (live row had started_at from run 1, completed_at from run 2)
- status defaults to FAILED so KeyboardInterrupt/SystemExit log truthfully
  instead of SUCCESS; SUCCESS/SKIPPED set explicitly on return
2026-10-09 12:20:38 +07:00
andrew 06f3545e48 feat(batch): log batch job execution status to batch_execution_jobs 2026-10-09 11:32:54 +07:00
andrew b5a8baeef4 feat(config): wire counting/weighing YAML sections through batch config 2026-10-09 11:28:44 +07:00
andrew 91b5296ef8 fix(batch): skip cleanly when no input videos (allow_empty) 2026-10-09 11:15:35 +07:00
andrew cc5935803f chore: revert unowned edits and remove spoofed 2026-10-09 artifacts 2026-10-09 11:11:21 +07:00
andrew 75401caa66 fix(batch): upsert per-camera weight metrics instead of blind UPDATE
Split services run weighing (06:00) before counting (08:00) for the same
date; on a fresh date no batch_runs rows exist yet, so the per-cam
UPDATE ... WHERE date/location/camera_id matched 0 rows silently and only
the FUSED upsert survived. Per-cam predicted_weight_g etc. showed 0 in
/api/db/date after counting filled the rows.

Upweight via INSERT ... ON CONFLICT DO UPDATE (weight columns only,
counts untouched) in new _upsert_weight_metrics helper; counting's later
count-column upsert likewise leaves weight columns alone, so both run
orders now persist both halves.

Tests: PYTHONPATH=src python3 -m unittest discover -s tests -p "test_*.py"
-> Ran 53, 49 pass, 2 pre-existing failures unchanged from 61ca7c2
(fusion n_valid_samples, consolidate fixture).
2026-10-08 17:26:00 +07:00
andrew 4bcd242dd3 feat(services,weight): split count/weight services, day-0 cycle handling, disable step-function GBM
- services: separate 08:00 counting and 06:00 weighing systemd units/timers,
  run_daily_counting.sh / run_daily_weighing.sh, install_service.sh update
- dashboard: guard /api/weight/coops against rows without weight data
- sim/day-0: CYCLE_START_DATE 2026-10-01 (day 0 = DOC arrival, counts only);
  consolidation skips cycle_day 0 artifacts (storage.py guard)
- weight: predict_chicken_weight(use_gbm=False) default. Retrained joblib
  (LGBM, 14:26) predicts a step function of cycle_day only (108.1 g days 1-5,
  140.1 g days 6-8, zero sensitivity to camera area); fallback Gompertz +
  allometric blend restored, varies per camera/day (37.2-115.7 g over days 1-7).
  Re-enable only after model retrained on early-day morphometry with
  features_dict/volumetric wired (see ponytail comment in growth_model.py).
  Covered by new tests/test_growth_model_gbm.py
- models/scripts: retraining tooling (train_weight_model.py,
  train_c23_focused_model.py), retrained joblib, historical_weights_avg.csv
- configs/template/requirements: cycle7 batch yamls, index.html, deps
- data: db/chicken_counts.db + reports refreshed from 2026-10-01..08 rerun

Tests: PYTHONPATH=src python3 -m unittest discover -s tests -p "test_*.py"
-> Ran 51, 49 pass. 2 pre-existing failures unchanged from baseline
(61ca7c2): fusion n_valid_samples 59!=98, consolidate fixture (day-0 date
conflicts with day-0 skip).
2026-10-08 17:02:21 +07:00
andrew 61ca7c2cc5 fix(weight,api): carry coop/location through consolidation, purge nan
Consolidation re-derived features/predictions without location/coop and
overwrote batch-written K1-L1 values with blanks; CSV reads then turned
blanks into literal "nan" and parquet rows fell back to bogus
FULL/FULL_CYCLE path inference.

- storage.py: pass location/coop from curation JSONs into
  aggregate_camera_features / build_cage_day_features_and_predictions
- dashboard.py: _enrich_records treats NaN/"nan" as missing;
  /api/weight/coops buckets and /api/weight/coop/<id> filter use
  row values instead of path inference
- tests: assert re-derived date-folder + merged rows keep K1/K1-L1
2026-10-07 12:38:46 +07:00
andrew 9abce58ac3 fix(sim): GPU preflight before daily batch runs
Skip loudly (exit 1, no symlinks/state touched) when nvidia-smi reports
<6000 MiB free or no driver: the 2026-10-07 cron OOM'd after the
retraining-backend container took 7.4 GB VRAM at startup.
2026-10-07 12:06:01 +07:00
andrew e22ad91384 feat(storage): parquet-only cycle_weight_parquet_data, auto-consolidated daily
- rename merged-output folder to cycle_weight_parquet_data, now a single
  CYCLE_WEIGHT_DIR_NAME constant shared with daily_size_comparison.py
  (xlsx default path + merged parquet lookups) and the dashboard.py
  coop/location skip-list, so the rename cannot half-apply again
- drop full_cycle_*.csv by default (235.8 MB vs 28.8 MB parquet on a
  49-day cycle, same rows); consolidate-parquets --with-csv restores them
- simulate_daily_cycle.sh consolidates after each successful batch
  (batch no longer execs) and only warns on consolidation failure
- verified: 6-date sim root consolidated 118427 rows == sum of daily
  parquets, 0 dupes on rerun, daily_size_comparison.xlsx generated,
  49 unit tests pass
2026-10-06 12:06:17 +07:00
andrew 4d9a56f446 chore(models): track cc-sukawarna-new-seg.pt segmentation weights 2026-10-01 16:42:01 +07:00
andrew a1813c18c4 fix(db): rebuild batch_runs to drop 5 index-orphan ghost rows (integrity ok) 2026-10-01 13:30:04 +07:00
andrew a12ac1a8cf docs: document true parallel_processes execution and daily full-cycle sim cron 2026-10-01 11:33:45 +07:00
andrew 1d676e392c feat(sim): add daily full-cycle simulation runner with K1-L1 floor config 2026-10-01 11:21:58 +07:00
andrew 61a1685a95 feat(batch): execute parallel_processes mode as true multi-process camera run 2026-10-01 11:21:58 +07:00
andrew e079678689 feat(config): tune early-cycle stage thresholds and switch detection weights to .pt 2026-10-01 11:21:58 +07:00
andrew 392b8fc9a9 feat(mortality): switch to dead-chicken-seg model with conf 0.3 / iou 0.5 2026-09-30 15:23:32 +07:00
andrew 5d69452276 fix(weight, api): update flock uniformity threshold to ±5% of median
- Update uniformity calculations in aggregation, curation, and dashboard endpoints from ±10% to ±5% of median
- Synchronize API documentation and unit tests for the 5% window
- Update SQLite database counts and ignore local weights directory
2026-09-14 08:53:12 +07:00
andrew 7cf25114c4 docs: sync edge-facing docs with central ERD v31.4.5
- CENTRAL_DASHBOARD_INTEGRATION.md: API_KEYS hierarchy note,
  new CYCLES close-out/feed-balance (Sec D), API_KEYS mapping
  (Sec E), MANUAL_INPUT feed-out fields (Sec F); central-only
  fields flagged not-yet-available from edge API
- RUN.md: complete endpoints table with coop/weight/mortality
  routes; Step 5 machine-auth note via central API_KEYS
- API.md verified current (edge-only, no changes needed)
2026-09-10 14:24:21 +07:00
andrew 11eddf3edb docs: sync ERD.md with central dashboard ERD v31.4.5
- USER_ACCESS: use central password field plus display_name,
  last_login, is_superuser, is_staff, is_active
- CYCLES: nullable end_date plus proposed_end_date,
  close_requested_at/by_id, feed_initial_balance(_date)
- MANUAL_INPUT: add feed_out_manual(_total)
- Add API_KEYS machine-credential table and relationships
- Remove ERD_central_dashboard.json snapshot (ERD.md is source of truth)
2026-09-10 14:01:54 +07:00
andrew 72123e7612 feat(weight, api): add frequency, excluded, and uniformity metrics
- Compute frequency (valid sample count), excluded (discarded outliers/duplicates), and uniformity (% within +/- 10% of median) during track curation and feature aggregation
- Expose frequency, excluded, and uniformity across all weight endpoints in dashboard.py (/api/weight/predictions, /api/weight/predictions/<date>, /api/weight/features/<date>, /api/weight/curation/..., and /api/db/date/<date>)
- Update API.md, ERD.md, CHANGELOG.md, and CENTRAL_DASHBOARD_INTEGRATION.md
- Add comprehensive test assertions in test_dashboard_weight_api.py and test_weight_estimation.py
2026-09-03 14:31:27 +07:00
andrew e138360a13 feat(weight, api): add camera location and coop identification to weight estimation
- Propagate parent coop (e.g. K1) and floor location (e.g. K1-L1) across feature aggregation, predictions, and curation storage
- Add REST API endpoints GET /api/weight/coops and GET /api/weight/coop/<coop_id>
- Support multi-coop non-colliding predictions and ?coop= / ?location= filtering
- Add dynamic farm root discovery and folder path fallback inference for legacy datasets
- Persist FUSED flock weight in SQLite batch_runs table with camera_id='FUSED'
- Update GET /api/db/date/<date> to return weight and coop metadata for all cameras
- Update ERD.md, CHANGELOG.md, API.md, and CENTRAL_DASHBOARD_INTEGRATION.md
- Add comprehensive unit tests in test_weight_estimation.py and test_dashboard_weight_api.py
2026-09-03 14:12:35 +07:00
andrew c738db6f92 docs: synchronize API, README, RUN, and ERD documentation with latest endpoints, storage lifecycle, and segmentation features 2026-08-28 08:14:37 +07:00
andrew d0e76f887b feat(storage, db): add automated storage lifecycle, validated video purging, and SQLite WAL recovery handlers
- Add storage lifecycle engine (storage_lifecycle.py) with multi-camera artifact validation and safe raw video purging
- Implement standalone 'cleanup' CLI command and --purge-raw-videos / --retention-days batch flags
- Standardize SQLite WAL mode with 60s busy timeout and auto-checkpointing in db_utils.py
- Add graceful shutdown and UPS power-cut recovery handlers (SIGTERM, SIGINT, SIGHUP, atexit)
- Add comprehensive unit tests in tests/test_storage_lifecycle.py
- Update RUN.md, CHANGELOG.md, and batch configs
2026-08-27 16:56:04 +07:00
andrew 23ba340707 feat(weight): add configurable Day 0 DOC weight and production deployment runbook 2026-08-27 16:02:45 +07:00
andrew 4878092c15 build: clean requirements.txt for universal cross-platform portability across x86_64, ARM64 Jetson, and Docker 2026-08-27 13:47:50 +07:00
andrew 655bf295ef fix(ui, weight): resolve dashboard template syntax and improve mask inertia axes calculation
- Fix static JavaScript syntax error in templates/index.html with Number() wrapper
- Enhance compute_metric_mask() with second-order central moments (inertia tensor) and minAreaRect fallback
- Add backup db ignore pattern and fix typo in .gitignore
- Update SQLite database with full cycle batch runs and add analytical Excel report workbooks
- Include daily weight GBM model artifact
2026-08-27 13:45:26 +07:00
andrew 429ee6be7a feat(weight): add multi-camera parquet consolidation, instance masking, and daily size comparison report
- Implement compute_metric_mask for instance segmentation polygon contour area and ellipse fitting
- Implement consolidate_full_cycle_datasets with multi-camera (CC1..CC4) discovery and FUSED aggregation
- Fix parallel worker race conditions in batch_runner.py during simultaneous camera parquet writes
- Implement daily_size_comparison.py generating daily_size_comparison.xlsx with ground-truth scale weights
- Add cycle7_batch_segmentation_masking.yaml and test_run_full_cycle7_segmentation_masking.sh with toggleable geometry mode
- Harden SQLite WAL concurrency across batch_runner.py and store_results.py with busy_timeout=60000 and synchronous=NORMAL
- Add unit tests for mask metrics and reports (32/32 tests passing)
- Update CHANGELOG.md, README.md, and RUN.md
2026-08-26 13:59:03 +07:00
andrew 0a5c8c508c docs: update ERD, API, RUN, README, and CHANGELOG with detection parquet and mortality workflows 2026-08-24 16:41:55 +07:00
andrew a1782e966a feat(weight): implement detection parquet generation and storage for weight estimation and retraining 2026-08-24 16:35:49 +07:00
andrew 024faaaeb2 feat(mortality): add dedicated inspector tab with split layout, filtering, and delete workflow 2026-08-24 16:11:50 +07:00
andrew b9ddd03d43 feat(ui): add green rectangle border highlight for selected camera card and right-align counter values 2026-08-24 15:41:11 +07:00
andrew 60bc7c712a feat(dashboard): upgrade camera indicators to pure CSS glowing status dots for universal Jetson/embedded compatibility 2026-08-24 15:38:23 +07:00
andrew 750eae1086 feat(dashboard): add live status indicator emojis (green, yellow, red) for cameras in sidebar 2026-08-24 15:35:41 +07:00
andrew 2e395f0f11 fix(dashboard): eliminate camera view focus-stealing and DOM flickering during multi-job batch processing 2026-08-24 15:31:15 +07:00
andrew eacd3dc93b docs: replace all Audrix references with Main Dashboard in ERD.md and API.md 2026-08-24 13:14:44 +07:00
andrew 19af5d1e41 docs: generalize Day 0 DOC arrival as headcount count only with cycle-specific weigh-in 2026-08-24 11:15:39 +07:00