CapPow commited on
Commit
0c1ebf8
·
verified ·
1 Parent(s): d67ff8a

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +157 -0
README.md CHANGED
@@ -1,3 +1,160 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ base_model: Qwen/Qwen3-VL-4B-Instruct
4
+ pipeline_tag: image-text-to-text
5
+ library_name: gguf
6
+ tags:
7
+ - herbarium
8
+ - biodiversity
9
+ - vision-language
10
+ - structured-output
11
+ - gguf
12
+ - llama.cpp
13
+ - gbif
14
+ language:
15
+ - en
16
  ---
17
+
18
+ # Herb-VISOR
19
+
20
+ **Visual Inspector for Specimen Observation & Recognition**
21
+
22
+ A 4B vision-language model that reads herbarium specimen images and emits structured, controlled-vocabulary JSON describing visible attributes (foliage, stem type, reproductive presence, and reference markers such as labels, barcodes, and scale bars). It reports what is visible on the sheet; it does not perform taxonomic identification.
23
+
24
+ Given a specimen image and its taxon name, the model returns schema-valid JSON with no prompt engineering.
25
+
26
+ - **Base model:** [Qwen/Qwen3-VL-4B-Instruct](https://huggingface.co/Qwen/Qwen3-VL-4B-Instruct) (Apache 2.0)
27
+ - **Method:** full-weight fine-tune, teacher-student distillation
28
+ - **Format:** GGUF (llama.cpp-native), runs offline on an 8 GB-class GPU
29
+ - **Code, validation, and documentation:** [GitHub repository](https://github.com/CapPow/herb-visor)
30
+
31
+ ## Files
32
+
33
+ | File | Purpose |
34
+ |---|---|
35
+ | `herb-visor-4b-q8.gguf` | model weights, q8 (recommended; runs in ~8 GB VRAM) |
36
+ | `herb-visor-4b-f16.gguf` | model weights, f16 |
37
+ | `herb-visor-4b-mmproj-f16.gguf` | vision projector (required for image input) |
38
+
39
+ The mmproj file is required. Pair it with either weight file.
40
+
41
+ ## Usage
42
+
43
+ Start a server with llama.cpp:
44
+
45
+ ```bash
46
+ llama-server \
47
+ --model herb-visor-4b-q8.gguf \
48
+ --mmproj herb-visor-4b-mmproj-f16.gguf \
49
+ --temp 0 \
50
+ -c 8192 \
51
+ --host 127.0.0.1 --port 8080
52
+ ```
53
+
54
+ The inference contract is deliberately minimal: no system prompt, no schema
55
+ instructions. The only text input is the taxon binomial (standard casing, e.g.
56
+ `Acer pseudoplatanus`), with the specimen image attached. Use `temperature 0`
57
+ for deterministic output. The model also returns valid JSON without a taxon
58
+ name; the name is included to aid reproductive-trait alignment.
59
+
60
+ A minimal client ([`infer.py`](https://github.com/CapPow/herb-visor/blob/main/infer.py), pure Python standard library):
61
+
62
+ ```bash
63
+ python infer.py path/to/specimen.jpg "Acer pseudoplatanus"
64
+ ```
65
+
66
+ Or via the OpenAI-compatible endpoint. Build the request payload in Python
67
+ (a base64 image is too large to pass as a shell argument), then send it:
68
+
69
+ ```bash
70
+ python3 <<'PY'
71
+ import json, base64
72
+ img = base64.b64encode(open("path/to/specimen.jpg", "rb").read()).decode()
73
+ payload = {
74
+ "messages": [{
75
+ "role": "user",
76
+ "content": [
77
+ {"type": "text", "text": "Acer pseudoplatanus"},
78
+ {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{img}"}}
79
+ ]
80
+ }],
81
+ "temperature": 0
82
+ }
83
+ open("/tmp/req.json", "w").write(json.dumps(payload))
84
+ PY
85
+
86
+ curl -s http://localhost:8080/v1/chat/completions \
87
+ -H "Content-Type: application/json" \
88
+ --data-binary @/tmp/req.json | python -m json.tool
89
+ ```
90
+
91
+ ### Example output
92
+
93
+ For a pressed *Acer pseudoplatanus* sheet:
94
+
95
+ ```json
96
+ {
97
+ "type": "PH",
98
+ "attached_photo": false,
99
+ "structures": {
100
+ "foliage": "present",
101
+ "foliage_type": "leaf",
102
+ "stem": "woody",
103
+ "phenology": {
104
+ "flower": false, "fruit": false, "pollen_cone": false,
105
+ "seed_cone": false, "sporulating": false, "reproductive_unknown": false
106
+ }
107
+ },
108
+ "refs": {
109
+ "label": true, "barcode": false, "stamp": false,
110
+ "crc": true, "scale_bar": true
111
+ }
112
+ }
113
+ ```
114
+
115
+ The full output schema is in the [repository](https://github.com/CapPow/herb-visor/blob/main/schema/schema.json).
116
+
117
+ ## Training
118
+
119
+ The model was trained by distilling a larger teacher (Qwen3.6-27B, `Qwen3.6-27B-UD-Q5_K_XL`), whose structured-JSON captions were the training ground truth. Training used two phases: phase 1 with full schema instructions in the prompt, and phase 2 with only the image and taxon name. Phase 2 bakes the schema into the weights, so end users need no prompt beyond the binomial. On the held-out test set, output was schema-valid, strict-parsed, controlled-vocabulary JSON in all 643 of 643 cases.
120
+
121
+ ## Evaluation
122
+
123
+ Accuracy was measured against human-validated labels on a 100-specimen blind sample (a single non-specialist annotator scored each field cold from the image, with no access to model predictions). Per-field accuracy is strong on reference markers and foliage; the weaker fields are stem type and stamp detection.
124
+
125
+ | Field | Accuracy |
126
+ |---|---|
127
+ | `structures.foliage` | 0.97 |
128
+ | `structures.stem` | 0.79 |
129
+ | `attached_photo` | 0.95 |
130
+ | `refs.label` | 0.99 |
131
+ | `refs.barcode` | 1.00 |
132
+ | `refs.stamp` | 0.70 |
133
+ | `refs.crc` | 1.00 |
134
+ | `refs.scale_bar` | 1.00 |
135
+ | `repro_visible` (category-level) | 0.88 |
136
+
137
+ Whole-specimen strict exact match (all 10 fields correct at once) was 0.438, against 0.484 for the 27B teacher. Distillation preserved teacher behavior closely, including its errors; the student did not exceed the teacher.
138
+
139
+ Speed: roughly 5.0 s/img for this model versus 68.6 s/img for the 27B teacher on the same hardware (single stream).
140
+
141
+ Full methodology, the label-free taxonomic-consistency check, and reproduction instructions are in the [GitHub repository](https://github.com/CapPow/herb-visor).
142
+
143
+ ## Limitations
144
+
145
+ - `repro_visible` is validated at the category level only (a reproductive structure is present). Fine-grained phenology (flower vs fruit vs cone type) was not human-validated.
146
+ - Ground truth is a single non-specialist annotator (n=100); some apparent errors are annotator-limited. Treat reported accuracies as a conservative floor.
147
+ - Output is a curator-assist candidate, not authoritative write-back.
148
+ - `type` is always `PH` on herbarium input and is not a discriminative result.
149
+
150
+ ## License and attribution
151
+
152
+ This model is a full-weight fine-tune of [Qwen/Qwen3-VL-4B-Instruct](https://huggingface.co/Qwen/Qwen3-VL-4B-Instruct), which is licensed under Apache License 2.0. Herb-VISOR is released under the same Apache 2.0 license. The weights were modified by fine-tuning on distilled teacher captions over herbarium specimen images.
153
+
154
+ Repository code is released under the MIT license. Training images are GBIF-derived and follow their source-institution terms; they are not redistributed here.
155
+
156
+ ## Citation
157
+
158
+ ```
159
+ [PLACEHOLDER: citation block]
160
+ ```