How to use from
llama.cpp
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh
# Start a local OpenAI-compatible server with a web UI:
llama serve -hf CopyleftCultivars/agri-vision-detector:F16
# Run inference directly in the terminal:
llama cli -hf CopyleftCultivars/agri-vision-detector:F16
Install from WinGet (Windows)
winget install llama.cpp
# Start a local OpenAI-compatible server with a web UI:
llama serve -hf CopyleftCultivars/agri-vision-detector:F16
# Run inference directly in the terminal:
llama cli -hf CopyleftCultivars/agri-vision-detector:F16
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git
cd llama.cpp
cmake -B build
cmake --build build -j --target llama-app
# Start a local OpenAI-compatible server with a web UI:
./build/bin/llama serve -hf CopyleftCultivars/agri-vision-detector:F16
# Run inference directly in the terminal:
./build/bin/llama cli -hf CopyleftCultivars/agri-vision-detector:F16
Use Docker
docker model run hf.co/CopyleftCultivars/agri-vision-detector:F16
Quick Links

AgriVision: on-device crop and plant-disease checker

Hippocratic License HL3-CL-ECO-EXTR-SV

A small set of models that run entirely in a phone's browser (ONNX Runtime Web). A photo of a field or a leaf goes in, and the phone finds the plants, names the crop, and says healthy or diseased with a likely condition. Nothing is uploaded. It is built by Copyleft Cultivars from open datasets, for smallholder and community growers, including the forest-conservation and Indigenous-knowledge work the nonprofit supports in Ecuador and Mexico.

This is a research prototype. No plant pathologist has checked any label. We have tested it in a phone-sized desktop Chrome window and in this page's self-test; we have not yet confirmed it on a range of real phones. Do not use it to decide a treatment.

Try it on your phone: no install, no account

  1. On your phone, open this link in Chrome. We have only tested Chrome; Safari and other browsers may work but are unchecked: https://copyleftcultivars-agri-vision.static.hf.space/
  2. Tap Load models. Wait until it says "ready". This downloads about 45 MB, so use Wi-Fi.
  3. Tap Take / choose a photo. Allow the camera if your phone asks. Photograph one leaf or one plant, close enough to fill much of the picture.
  4. Read the result. Green is healthy, red is diseased, yellow is unsure and grey is too small to judge. If it says unsure, trust that.

The models run inside your phone's browser. Your photos are never uploaded and no account is needed. The page downloads the models again on each visit unless your browser keeps them; offline use is not set up yet.

If something goes wrong:

  • Stuck on "Load models" or the page reloads: the phone is probably short on memory. Close other tabs and apps, keep "960 px (lighter)" selected, and try again.
  • The camera does not open: choose a photo from your gallery instead.
  • It is slow: a phone can take several seconds per photo. Wait for it to finish.
  • Still not working: tell us which phone and browser you used, at https://huggingface.co/CopyleftCultivars/agri-vision-detector/discussions

To host your own copy, see RUN.md.

Code, lab notebook and training scripts: https://github.com/CopyleftCultivars/agri-vision-detector (not public yet). Every number below is tied to a log in artifacts/ and a numbered section of LAB_NOTEBOOK.md.

What is in this repo, and how to run it

This section is for people who want the files or the training code. To simply use it, see "Try it on your phone" above. Commands for running it yourself are in RUN.md.

file what it does size measured
phone_site/models/det1280.onnx YOLO11n plant detector, 3 classes (common bean, cowpea, sorghum), 1280 px input 11.1 MB test mAP50 0.704, mAP50-95 0.428 (n=1,246)
phone_site/models/det960.onnx same detector trained at 960 px, for slower devices 11.1 MB mAP50 0.691, mAP50-95 0.385
phone_site/models/crop18.onnx MobileNetV3-L, names 1 of 18 crops from a plant crop 11.9 MB about 0.60 accuracy at a new site (site-disjoint CV, n=2,824)
phone_site/models/diag_int8.onnx MobileNetV3-L, healthy vs diseased plus a 12-way condition, INT8 3.4 MB see the table below
phone_site/ the phone page (index.html, app.js) with ONNX Runtime Web bundled in ort/ 14 MB runs in a browser, no server code
infer_onnx.py, infer_tiny.py computer inference, ONNX Runtime only
artifacts/*/best.pt PyTorch checkpoints for every ONNX file, with SHA256SUMS
artifacts/crop18_web500_v2/ newer crop model (about 0.62 in the same cross-validation); not in the phone page yet 11.9 MB
artifacts/heads_v1, heads_v2, d1/, diagnose.py, patches/ d1-omni-600M heads, its GGUF files and the llama.cpp patch, for the experimental heads path
training and evaluation scripts, LAB_NOTEBOOK.md, docs/HOWTO.md how everything was built and measured

phone_site/models/SHA256SUMS-style checks: det1280 = artifacts/yolo11n_ft1280, det960 = artifacts/yolo11n_v2_960, crop18 = artifacts/crop18_web_v1, diag_int8 = artifacts/cnn_tiny_v1 (INT8 percentile), byte for byte.

How it compares

Comparison figure

The one fair question people ask is whether a general vision-language model such as Qwen3.5-2B could replace the small classifiers. We tested the base model with no training (notebook section 60), on photos sampled from the same maize sets, and compared it with what we trained.

model KaraAgro maize (Ghana), healthy vs diseased Tanzania maize, healthy vs diseased size / how it runs
majority class 0.694 0.672
CNN trained on web photos only (PlantWild, PlantSeg, PlantDoc) 0.535-0.555, below majority 0.66, below majority 3.4 MB INT8, in the browser
Qwen3.5-2B zero-shot (Q8_0 GGUF, thinking off, one JSON prompt) acc 0.711 [0.61, 0.80], balanced 0.775 (n=90) acc 0.717 [0.63, 0.79], balanced 0.775 (n=120) about 2.7 GB with its vision file; ran on a server GPU at 1.6 s per photo
d1-omni-600M trunk head (frozen, small trained head) acc 0.784, balanced 0.805 (n=768) not measured 0.6B model plus llama.cpp
d1-omni-600M zero-shot crop ID 20.9% (calls most crops "maize"); disease score not usable not measured
AgriVision CNN trained with other field sources, this source held out acc 0.801 [0.771, 0.828], balanced 0.805 (n=768) 0.92-0.95 (n=9,356) 3.4 MB INT8, in the browser

How to read it:

  • Qwen3.5-2B finds obvious damage (necrosis 34 of 40, fall armyworm 27 of 30) and misses maize streak virus (22 of 70 right), calling it healthy. It names the crop correctly on 89% of photos.
  • On KaraAgro it is close to the field-trained CNN (balanced 0.775 vs 0.805; the intervals overlap). On Tanzania it is far below (0.717 vs 0.92-0.95).
  • The Qwen numbers come from 90 and 120 sampled photos and the others from full sets, so this is a rough comparison, not a ranking. One prompt was tried. Fine-tuned Qwen was not tested.
  • Our reading: keep the small specialist classifiers on the phone, and let a language model sit on top reading the classifier's text output for chat and a second opinion.

Other held-out results (full list in docs/MODEL_CARD_DETAILED.md):

task result
healthy vs diseased, web-trained, tested on PlantDoc (n=2,523) CNN 0.943 vs d1 head 0.915
same web-trained CNN on tropical field photos (KaraAgro) 0.535-0.555, below majority
external test, never trained on: CCMT (Ghana cashew/cassava/maize/tomato, n=25,122) balanced accuracy 0.83-0.88
pest species, IP102, 97 classes (n=2,969) top-1 0.726, top-5 0.914, balanced top-1 0.537
Amazonian/tropical useful-plant species ID, 11 taxa from GBIF photos 0.818 vs 0.134 majority (internal experiment, not in the bundle)

Training history

Hardware: one Tesla M40 in a dual-GPU workstation with torch 1.13.1, plain torch/torchvision/ONNX Runtime. HF transformers generation loops are banned on this box after repeated hard power losses, so d1 was never fine-tuned locally; it runs through a patched llama.cpp. Detector v2 ran once on a Kaggle T4. All splits are by site or capture date, and results are leave-one-source-out wherever a held-out source existed.

  1. Detector (notebook 4, 16-18, 28, 47). YOLO11n on 8,160 Artemis / Image Safari field photos (bean, cowpea, sorghum). 640 px: mAP50-95 0.349. 960 px: 0.385 (Kaggle) and 0.398 (local). 1280 px fine-tune: 0.428, which is what ships. The gain comes from better boxes on medium and large plants; tiny-plant recall stayed at 0.20. Resolution and 25 extra epochs are confounded in that last step.
  2. d1-omni zero-shot (notebook 4.1). 20.9% crop accuracy on 204 field photos, almost everything called "maize". This is why we trained heads.
  3. d1 trunk heads (17, 21, 36). Small heads on frozen d1 features. Good in-distribution (crop 91%), poor across sources (31% on a different campaign). Duplicate photos across PlantDoc, PlantWild and PlantSeg were found and removed (up to 4 points of inflation).
  4. Tiny CNN diagnoser (26-33, 40). MobileNetV3-L fine-tuned end to end. Matches or beats the d1 heads at about 1/35 of the size. Web-only training fell below the majority baseline on tropical field photos; adding other field sources fixed most of it. INT8 works only with percentile calibration.
  5. Crop ID (39, 49-54). Site-disjoint 18-crop accuracy 0.52 from Safari photos alone. Adding GBIF/iNaturalist web photos gave 0.60 (150 per crop) and 0.62 (500 per crop). A control that duplicated Safari rows instead gave 0.53, so photo diversity, not volume, is what helped.
  6. Things that did not work, kept on purpose (44-46, 48, 55). Test-time augmentation and a seed ensemble, strong augmentation, 320 px input, EfficientNet-B0, temperature calibration, AdaBN and pseudo-labelling.
  7. More field data for disease (56-59). Tanzania maize (9,356 photos), AI-labelled Safari photos (training-only weak labels), and 1,318 Claude-labelled Ecuadorian Amazon field photos each gave no measurable gain on the held-out sets. Seed-to-seed spread (about 0.05) was larger than every difference. The Ecuador labels reached kappa 0.78 between two Claude labellers, and both labellers are the same model family.
  8. Qwen3.5-2B zero-shot (60). Described above.

What is next: a real-phone test, an INT8 version of the newer crop model, expert (pathologist) review of labels, and field sets beyond maize (rice from Bangladesh has just been downloaded: 1,560 in-field photos, not yet evaluated).

Limitations

  • The detector covers 3 of 18 crops. Crop ID is about 0.60 for 18 classes, which is not deployable.
  • Disease accuracy is limited by data, not model size. Every source-held-out gain came from adding field photos from other farms or countries, and models do not transfer well from lab or web photos to field canopy photos.
  • Random splits leak: CCMT scores 0.99 within its own source and 0.84-0.87 when never trained on. Use the held-out rows.
  • Disease labels come from web-scraped and lab-style datasets and AI labellers. Nothing was reviewed by a plant pathologist.
  • Small test sets (e.g. about five images per pest species) have wide intervals.
  • Not run on a phone, no latency measured, TFLite export failed four times (ONNX is the mobile format).
  • Amazonian and medicinal plants: public GBIF photos were used for species identification only. Community consent and benefit-sharing are covered under Licensing below.

Licensing

Each part follows the licence of the work it builds on. Full texts are in the repo.

part licence
Detector weights (det960, det1280, artifacts/yolo11n_*) and the detector training and evaluation scripts that use Ultralytics AGPL-3.0 (Ultralytics YOLO11), LICENSE-AGPL-3.0.txt
d1-omni-600M GGUF files (d1/), the head weights (artifacts/heads_v1, heads_v2) and the llama.cpp patch LFM Open License v1.0 (Liquid AI), d1/LICENSE-LFM-Open-License-v1.0.txt
Tiny CNN diagnoser and crop-ID weights (fine-tuned from torchvision MobileNetV3, BSD-3-Clause), ONNX and PyTorch Hippocratic License 3.0, HL3-CL-ECO-EXTR-SV (LICENSE.md); the BSD-3 notice is kept in LICENSE-torchvision-BSD-3.txt
ONNX Runtime Web (phone_site/ort/) MIT, Microsoft
Everything else we wrote: phone page, scripts, notebook, model card, figures, label files Hippocratic License 3.0, HL3-CL-ECO-EXTR-SV

Amazonian and medicinal plants: any use on Indigenous or community plant knowledge needs the communities' consent and the access-and-benefit-sharing rules that apply (Brazil Law 13.123/2015 and SisGen, Peru Law 27811, Andean Decision 391, the Nagoya Protocol, CARE principles). Those are not covered by any licence here.

Sources of the training data and credits: docs/MODEL_CARD_DETAILED.md section 5. Credits: Artemis and Image Safari (CIAT / Alliance of Bioversity International), Liquid AI d1-omni, Ultralytics YOLO11, PlantDoc, PlantWild, PlantSeg, IP102, KaraAgro, Makerere, Pretoria, CCMT, Cassava Leaf Disease.

Downloads last month
16
GGUF
Model size
0.4B params
Architecture
lfm2
Hardware compatibility
Log In to add your hardware

8-bit

16-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support