Skip to content

Releases

v0.5.0

Choose a tag to compare

@github-actions github-actions released this 08 Nov 22:02
f398550
  • Explanations saved per scan and citation badges (#74): every explanation shown for a scan is copied to a new SQLite table scan_explanations, and Scan Detail falls back to that copy when the API cannot be reached, so it stays readable in airplane mode even after switching the app language (a note says which language it was saved in). Citations are now badges (publisher · section) that expand on tap to the full reference (title, publisher, year, pages) with an Open source button. The Result screen waits until the scan is saved before requesting, so one diagnosis spends one request.
  • Cited explanations in the app (#37): Result and Scan Detail show an explanation card for confident, non-healthy diagnoses with a skeleton while loading, the summary, numbered next steps, the cited source and section (publisher, year, pages), an AI disclaimer and, when read from the phone, a "saved offline" note. app/src/services/explanations.ts sends only (crop, disease_class, severity, language) to POST /explanations through TanStack Query (@tanstack/react-query 5.104.5) and keeps answers in a new SQLite table explanations keyed by those four values, read first so answers stay available offline and repeated diagnoses do not spend the hourly quota. not_covered refusals are not kept. Offline, signed-out, rate-limited (429) and unavailable states have their own es/en messages, with a retry button where it helps.
  • Explanation cache, privacy guard and rate limit (#50): POST /explanations answers are cached in process by (crop, disease_class, severity, language) only, so repeated diagnoses (from any user) skip Gemini; concurrent misses on one key make a single call, and model failures and refusals are not cached. The service refuses classes outside the crop's model taxonomy, and tests check every supported prompt contains only those four values (no names, emails, uid, coordinates or request headers). Each user (Firebase uid, not IP) may send 20 requests per hour (slowapi); request 21 gets 429 rate_limited with Retry-After. Unauthenticated and invalid requests do not spend quota.
  • POST /explanations (#36): for an authenticated user and a diagnosis (crop, disease_class, severity, language) only, retrieves up to 4 passages from the local RAG index and asks Gemini (google-genai, GEMINI_MODEL) for a plain-language summary and next steps as JSON, citing passages by id. The response lists source_title, publisher, section, pages and URL for each cited section. It declines (covered: false) for healthy plants, when no passage matches, or when the model does not cite a provided passage; it returns 503 when Gemini or the index is unavailable. Request bodies reject any other field.
  • Local RAG index and retriever (#49): api/scripts/build_rag_index.py turns chunks.jsonl into a byte-reproducible TF-IDF index (api/.cache/rag/index.json), and RagIndex.retrieve(crop, disease_class, query, k) filters by crop and disease class and ranks by cosine similarity, keeping source, section, pages and URL for citations. Queries are built only from (crop, disease_class, severity) with bilingual keywords, weighted toward symptoms for watch and control for actNow. Sections can now exclude interleaved blocks, which removes the reference list printed mid-column in the CORBANA bulletin.
  • Cacao and banana RAG sources (#73): CATIE's Guía para el manejo integrado de enfermedades en el cultivo de cacao (2021) for monilia and black_pod, CORBANA's Manejo de la Sigatoka negra bulletin (2011) for black_sigatoka, and FAO's Fusarium TR4 technical manual (2014, English) for fusarium_wilt, with pinned checksums. Every disease class of coffee, cacao and banana now has cited chunks (86 in total), checked by a test. The chunker removes line-break hyphens for sources marked soft_hyphens and spaces before punctuation.
  • Agronomic document fetcher and section chunker for RAG (#35): api/rag_sources.toml lists official sources with pinned SHA-256 checksums and the sections to index; api/scripts/fetch_agronomic_docs.py downloads them into the git-ignored api/.cache/rag/, extracts PDF text (pypdf + fonttools, new rag extra), and writes chunks.jsonl with (source, section, pages, crop, disease_classes) metadata and a per-class coverage report. The first source is ICAFE's Guía técnica para el cultivo de café (2020), covering all five coffee disease classes.
  • End-to-end multi-tenant sync contract verification and Render deployment configuration (#48): shared fixture-based contract tests (app/src/services/fixtures/sync_contract.json, validated by api/tests/test_contract.py and app/src/services/__tests__/contract.test.ts) asserting 100% schema and field parity for farms, plots, and scans, idempotent re-sync and tenant isolation; and render.yaml Blueprint specification for deploying the FastAPI backend to Render's free tier with uv, Python 3.12, health check (/health), auto-deploy from main, and secret files for Firebase Admin.
  • Account settings and local data claiming (#72): the Settings account card shows the signed-in email, last sync time (persisted in AsyncStorage), pending change count, a Sync now button, and Sign out with a confirmation dialog (also used on the Account screen). On the first sign-in on a device, anonymous local farms, plots and scans are claimed for that account and synced; records the API refused earlier are re-queued. Data synced by a different account is left untouched.
  • Android sync engine (#47): app/src/services/sync.ts pushes pending farms, plots and scans to the API in dependency order (farms, plots, scans in batches of 100, then deletions), falls back from POST to PATCH on 409, treats 404 on delete as done, marks API-refused records failed, and leaves everything pending when a run stops offline or on a 401/5xx. Outcomes are recorded only if the row was not edited during the run. app/src/services/cloudinary.ts resizes scan photos to a 1280 px longer side and uploads them with API-signed parameters. Sync runs on sign-in, when connectivity returns (@react-native-community/netinfo), on app foreground, and on tapping the new Home sync pill, which pulses while syncing and morphs into a checkmark (static with reduce motion).
  • Firebase Auth email/password in the app (#34): app/src/services/auth.ts (Firebase JS SDK with AsyncStorage session persistence, lazily initialized from EXPO_PUBLIC_FIREBASE_*, error codes mapped to es/en messages), a Zustand session store, Sign In, Sign Up and Account screens with form validation, a TextField UI primitive, a Settings account card, and app/src/services/api.ts, which attaches Authorization: Bearer <idToken> when signed in and retries once with a refreshed token on 401. Diagnosis, history and local farms keep working without an account or without Firebase configured.
  • Idempotent batch POST /scans/sync (client UUIDs, last write wins on updated_at, tombstones, per-item created/updated/unchanged/rejected results), GET /scans with farm_id/plot_id/crop filters, and POST /uploads/scan-signature returning signed Cloudinary upload parameters scoped to users/{uid}/scans with a 1280 px limit, plus User A vs. User B isolation tests (#46).
  • CRUD /farms and CRUD /plots in api/ with client-generated UUID v4 IDs, ownerUid filtering on every Firestore read and write (OwnedRepository over a DocumentStore protocol), soft deletes with farm-to-plot cascade, 404 for other users' records, 409 for duplicate IDs, and User A vs. User B isolation tests (#33).
  • FastAPI core in api/: create_app factory (healthycropping_api.main:app), environment settings, public GET /health, Pydantic v2 schemas, structured {"error": {"code", "message"}} responses, CORS, a Firebase ID token verification dependency (firebase-admin) protecting GET /me (401 for missing, malformed, or expired tokens), and deny-all firestore.rules with firebase.json (#32).
  • Multi-crop offline diagnosis in the app: banana model registry bundled in app/src/ml/models/banana/, banana selectable on the Home screen next to coffee and cacao, with tests for registry parity, model resource names, and the coming-soon state for crops without a model (#31).
  • Float16 TFLite banana model export (ml/scripts/export_banana_tflite.py, ml/models/banana/banana_v0.1.0_fp16.tflite, 6.06 MB, 97.50% test accuracy with 0.00 pp drop vs Keras and 100.0% top-1 agreement), --threshold-floor export option, confidence threshold 0.80 (98.45% test precision at 97.0% coverage), ml/models/banana/registry.json, and Banana Model Card (docs/MODEL_CARD.md §4) (#71).
  • Banana MobileNetV3-Large frozen baseline (97.00% test accuracy, 0.9676 Macro-F1) and top-30 fine-tuned model (97.50% test accuracy, 0.9731 Macro-F1), CLI script (ml/scripts/train_banana.py), per-source evaluation (ml/scripts/evaluate_by_source.py), confusion matrices, and Grad-CAM visual explanations in docs/EXPERIMENTS.md (#30).
  • Banana leaf dataset pipeline: BananaLSD (OriginalSet only, CC BY 4.0) and NM-AIST Banana Leaves Imagery (Zenodo 7670326, CC BY 4.0) downloaders, HTTP Range extraction of image subsets from multi-gigabyte ZIP archives (ml/src/healthycropping_ml/remote_zip.py), ml/configs/banana.yaml, ml/scripts/prepare_banana.py, and the data report (docs/data_reports/banana.md, docs/assets/data_reports/banana_grid.png): 1,313 deduplicated images (391 healthy, 622 black_sigatoka, 300 fusarium_wilt) across 770 groups with zero cross-split leakage (#29).
  • Float16 TFLite cacao model export (ml/scripts/export_cacao_tflite.py, ml/models/cacao/cacao_v0.1.0_fp16.tflite, 6.06 MB, 91.73% test accuracy with 0.00 pp drop vs Keras and 100.0% top-1 agreement), validation-calibrated confidence threshold 0.51 (90.15% val precis...
Read more

v0.2.0 — Offline Android App & Coffee Diagnosis

Choose a tag to compare

@keylorpineda keylorpineda released this 16 Oct 21:35

Added

  • Offline-first SQLite persistence (expo-sqlite, expo-crypto), repository layer for farms, plots, and scans with sync queue metadata, History screen with multi-filter and swipe-to-delete with undo, Scan Detail screen with farm/plot location assignment, and Farms/Plots CRUD screens (#26).
  • Camera screen with viewfinder framing guide and shutter flash, crop-specific photo tips modal, analyzing sweep-line animation, and result screen with severity progress meter, confidence breakdown, pop-in status badge with haptics, low-confidence retake state, and agronomic disclaimer (#25).
  • On-device TFLite inference pipeline (app/src/ml/) with expo-image-manipulator, jpeg-js RGB decoding, training normalization, react-native-fast-tflite, threshold calibration, and Jest cross-platform tensor parity test (#24).
  • Onboarding (3-slide educational flow with mandatory agronomic disclaimer acceptance), Home (camera-first layout, primary Scan CTA, crop selector chips, offline status pill, and empty state), and Settings screens (instant es/en language switcher, light/dark theme toggle, model version, dataset licenses) (#23).
  • Reusable UI component library in app/src/components/ui/ (Button, Card, Chip, Badge, Sheet, Toast, Skeleton, EmptyState, ProgressMeter) with spring micro-interactions, haptics, >= 48 dp touch targets, reduced motion support, and RNTL unit tests (#22).
  • Agricultural design tokens (app/src/theme/) covering colors, typography, spacing, radii, elevation, and motion with dark/light themes and WCAG 2.1 AA mathematical contrast tests (#21).
  • ThemeProvider and useTheme() hook integrating user theme preference with system appearance and reduced motion accessibility (#21).
  • Expo SDK 52 Android application setup (app/app.json, app/package.json) with package com.keylorpineda.healthycrop, New Architecture, and Expo Router (#20).
  • Internationalization subsystem (app/src/i18n/) with Spanish default, English secondary, symmetric translation keys, and mandatory agronomic disclaimer (#20).
  • Zustand preferences store (app/src/stores/preferences.ts) managing locale, light/dark/system theme, and onboarding state (#20).
  • Jest + React Native Testing Library configuration (jest-expo) with native module mocks and unit tests (#20).

v0.1.0 — Foundation & Coffee ML

Choose a tag to compare

@keylorpineda keylorpineda released this 16 Oct 19:52

Added

  • Phase 0 repository foundation, monorepo workspace configuration (pnpm + uv), and .gitignore / .gitattributes / .editorconfig rules.
  • GitHub Community Standards (LICENSE, CODE_OF_CONDUCT.md, CONTRIBUTING.md, SECURITY.md, SUPPORT.md, CITATION.cff, CODEOWNERS, issue templates, PR template, and dependabot.yml).
  • Project documentation (AGENTS.md, docs/PLAN.md, docs/ARCHITECTURE.md, docs/DATASETS.md, docs/MODEL_CARD.md, docs/EXPERIMENTS.md, docs/FIELD_VALIDATION.md, docs/DEVLOG.md, and Spanish setup guide docs/SETUP_SERVICES_ES.md).
  • CI and release GitHub Actions workflows (.github/workflows/ci.yml and .github/workflows/release.yml) and empty test suites for app/, api/, and ml/.
  • Idempotent, SHA-256 verified coffee dataset downloaders (ml/scripts/download_rocole.py, ml/scripts/download_bracol.py) with truncated-ZIP recovery for BRACOL (#13).
  • Coffee dataset preparation pipeline (ml/configs/coffee.yaml, ml/scripts/prepare_coffee.py, ml/src/healthycrop_ml/preprocess.py, dedup.py, split.py) performing EXIF orientation correction, 224x224 RGB conversion, perceptual-hash deduplication (imagehash.phash), and grouped stratified 70/15/15 splitting (#14).
  • Coffee dataset report (docs/data_reports/coffee.md), 224x224 sample grid (docs/assets/data_reports/coffee_grid.png), and < 50 training-image merging evaluation (#15).
  • Frozen-backbone MobileNetV3-Large baseline training pipeline (ml/src/healthycrop_ml/model.py, evaluate.py, train.py, ml/scripts/train_coffee.py, ml/notebooks/01_coffee_training.ipynb), confusion matrix (docs/assets/confusion_matrices/coffee_baseline.png), and baseline metrics (79.72% test accuracy, 0.7135 test Macro-F1) in docs/EXPERIMENTS.md (#16).
  • Top-block MobileNetV3-Large fine-tuning, validation logit bias calibration (82.75% uncalibrated / 81.35% calibrated test accuracy, 0.8701 4-major-class F1), confusion matrix (docs/assets/confusion_matrices/coffee_finetuned.png), and per-class Grad-CAM visual explanations (ml/src/healthycrop_ml/gradcam.py, docs/assets/gradcam/coffee_gradcam.png) (#17).
  • Float16 TFLite export pipeline (ml/src/healthycrop_ml/export_tflite.py, ml/scripts/export_coffee_tflite.py): 6.06 MB coffee model at 81.12% test accuracy (0.23 pp below Keras), validation-calibrated confidence threshold 0.79 (90.9% accepted precision), ml/models/coffee/registry.json, and the shared preprocessing fixture ml/fixtures/preprocessing_fixture_224.json (#18).
  • Coffee model card (docs/MODEL_CARD.md §2): intended use, data, Keras vs TFLite metrics, per-class results with abstention coverage, Grad-CAM, and limitations; TFLite export results in docs/EXPERIMENTS.md (#19).