Instructions to use amih/scoutreader-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use amih/scoutreader-2 with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
ScoutReader 2, from Seferehov
Browse filesFiles changed (8)
- .gitattributes+1
- README.mdAdded+90
- adapter_config.jsonAdded+48
- adapter_model.safetensorsAdded+3
- examples/spine-hebrew.jpgAdded
- examples/spine-latin.jpgAdded
- read_spine.pyAdded+41
- requirements.txtAdded+5
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines3334353632 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textexamples/spine-latin.jpg filter=lfs diff=lfs merge=lfs -text
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990---license: apache-2.0base_model: Qwen/Qwen3-VL-2B-Instructlibrary_name: peftpipeline_tag: image-text-to-textlanguage: - he - entags: - lora - qwen3-vl - ocr - book-spines - hebrew - libraries---
# ScoutReader 2: read a book spine, fast, in Hebrew or English
ScoutReader 2 reads the title and author printed on a book spine and answers one line, `TITLE | AUTHOR`, or `NONE` when itcannot. It is a LoRA add-on (rank 64, attention and MLP layers, plus the vision-language merger trained in full) for**Qwen3-VL 2B Instruct**, trained for Hebrew and Latin spines. **About 0.8 s per spine on a GTX 1080 from 2016**, against5.7 s for Qwen3-VL 8B.
| Spine | ScoutReader 2 reads ||---|---|| <img src="examples/spine-hebrew.jpg" width="360"> | `צלה של הרוח \| קרלוס רואיס סאפון` (1.0 s) || <img src="examples/spine-latin.jpg" width="360"> | `FOREIGN PARTS \| Janice Galloway` (0.6 s) |
It runs in production in [Seferehov](https://github.com/amih/seferehov) ([seferehov.com](https://seferehov.com)), a sharedmap of free street libraries where readers photograph a shelf and local AI models read every book on it. There it is the**fast first reader**: when a catalogue knows its reading and PaddleOCR finds at least half of the reading on thepicture, the spine is settled and the big model is not asked.
## Use it
```bashpip install -r requirements.txtpython read_spine.py examples/spine-hebrew.jpg examples/spine-latin.jpg```
Give it one spine, turned level. Seferehov cuts spines out of shelf photos with[StairsCutter](https://huggingface.co/amih/stairscutter) and reads each one both ways up; it was taught to answer `NONE` for a spineupside down. The prompt, picture size and decoding in `read_spine.py` are the app's own and should be kept as they are.
## How well it works
**198 real spines** from shelf photos, cut by the app and checked by a person (answer key v3), never used in training(the 120 of them from the author's own photos are the `test` split of [Seferehov spines](https://huggingface.co/datasets/amih/seferehov-spines)):
| Reader | Hebrew titles right | Latin titles right | Exact titles | Seconds per spine ||---|---|---|---|---|| Qwen3-VL 2B, as is (lab 056) | about 36% overall | | | || ScoutReader (rank 32, Hebrew data only) | 85.2% | 53.1% | 39.9% | 0.75 || **ScoutReader 2** | **85.9%** | **77.6%** | **50.5%** | **0.79** || Qwen3-VL 8B, as is | 90.6% | 93.9% | 52.0% | 5.71 |
**As a first reader** (the way the app uses it), with the catalogue asked about every reading:
- It **settles 45.1%** of the 198 spines, and **98.9% of those are right** (1 wrong: a very hard spine where it read "I Won't Let You Go" for "I Won't Die Hungry", and a real book of that name was found).- ScoutReader 2 first and Qwen3-VL 8B for the rest: **94.4% right**, against 92.8% for the 8B alone.- On the public [fixed-9 shelf benchmark](https://github.com/amih/seferehov/tree/master/bench/fixed-9) (9 photos, 58 books): the same 50 of 58 books found, 0 wrong books settled, and about 8% fewer big-model calls per book found.
## Training
- **Data:** 18,000 synthetic Hebrew spine strips and 5,995 synthetic Latin strips (rendered text); real spines from public street-library photos taken by the app's readers (175 Hebrew, 39 Latin, the training half only) and 43 Latin spines from the author's own shelves, each real spine shown 4 times. Other readers' home shelves are never used.- **Setup:** LoRA rank 64, alpha 128, dropout 0.05, on the language model's q, k, v, o, gate, up and down projections; the vision-language merger trained in full; the vision encoder frozen. 2 passes, 6,466 steps, effective batch 8.- **Hardware:** one GTX 1080 (8 GB), about 11 hours, peak memory 6.6 GB.
What did not work, for the curious: a small CRNN trained from scratch (0.5%: no Hebrew starting point); real data alone(15% Hebrew with 175 spines); a 2B "corrector" of the big model's readings (broke 41 right titles).
## Limits
- **Not a general OCR model.** It reads spines and covers; it answers one line.- Hebrew is its strength; Latin trails the 8B model (77.6% against 93.9%).- Exact titles are hard: about half are letter-perfect. In the app a catalogue match decides whether a reading is used.- Like any reader, it can produce a believable title for an unreadable or blank picture. The app's guard against this is the PaddleOCR check above: in a lab run on 30 Nov 2026, without that check, it settled 3 wrong books on blank cut-outs (a picture scrap, a bare shelf board, a dark spine).
## Licence and credit
The adapter: Apache-2.0, like Qwen3-VL. Made by Ami Heines with Claude Code, in the Seferehov lab (experiment 088).Questions and results: [Discussions](https://github.com/amih/seferehov/discussions).123456789101112131415161718192021222324252627282930313233343536373839404142434445464748{ "alora_invocation_tokens": null, "alpha_pattern": {}, "arrow_config": null, "auto_mapping": { "base_model_class": "Qwen3VLForConditionalGeneration", "parent_library": "transformers.models.qwen3_vl.modeling_qwen3_vl" }, "base_model_name_or_path": "Qwen/Qwen3-VL-2B-Instruct", "bias": "none", "corda_config": null, "ensure_weight_tying": false, "eva_config": null, "exclude_modules": null, "fan_in_fan_out": false, "inference_mode": true, "init_lora_weights": true, "kasa_config": null, "layer_replication": null, "layers_pattern": null, "layers_to_transform": null, "loftq_config": {}, "lora_alpha": 128, "lora_bias": false, "lora_dropout": 0.05, "lora_ga_config": null, "megatron_config": null, "megatron_core": "megatron.core", "modules_to_save": [ "merger" ], "monteclora_config": null, "peft_type": "LORA", "peft_version": "0.21.3", "qalora_group_size": 16, "r": 64, "rank_pattern": {}, "revision": null, "target_modules": ".*language_model.*\\.(q_proj|k_proj|v_proj|o_proj|gate_proj|up_proj|down_proj)", "target_parameters": null, "task_type": null, "trainable_token_indices": null, "use_bdlora": null, "use_dora": false, "use_qalora": false, "use_rslora": false, "velora_config": null}123version https://git-lfs.github.com/spec/v1oid sha256:7c2883cf1d9397cadc32a12364d20eb60658285040725411822e7de3f9c017e0size 3796765761234567891011121314151617181920212223242526272829303132333435363738394041"""Read the title and author on a book spine with ScoutReader 2 (Qwen3-VL 2B + this LoRA adapter).
pip install -r requirements.txt python read_spine.py examples/spine-hebrew.jpg examples/spine-latin.jpg
The picture should be one spine, turned level (the way its title reads, left to right or right to left). Seferehovreads each cut-out both ways up and keeps the reading a catalogue or OCR confirms. Prompt, picture size and decodingare the app's own (fastread/fast_read.py): longest side at most 1024 px, at least 96 px high, greedy, 80 tokens.Answer: "TITLE | AUTHOR", or "NONE" when it cannot read it (it was taught to say NONE for an upside-down spine)."""import sys, timeimport torchfrom PIL import Imagefrom peft import PeftModelfrom transformers import AutoProcessor, Qwen3VLForConditionalGeneration
BASE = "Qwen/Qwen3-VL-2B-Instruct"ADAPTER = sys.argv[sys.argv.index("--adapter") + 1] if "--adapter" in sys.argv else "."PROMPT = ("This is one book spine or cover. Read its title and author exactly as printed, in the original language " "and script. Answer one line: TITLE | AUTHOR. If unreadable answer NONE.")
def load(path, long=1024): im = Image.open(path).convert("RGB") w, h = im.size if h < 96: im = im.resize((round(w * 96 / h), 96)); w, h = im.size k = long / max(w, h) return im.resize((max(32, round(w * k)), max(32, round(h * k)))) if k < 1 else im
device = "cuda" if torch.cuda.is_available() else "cpu"model = Qwen3VLForConditionalGeneration.from_pretrained(BASE, dtype=torch.float16 if device == "cuda" else torch.float32)model = PeftModel.from_pretrained(model, ADAPTER).merge_and_unload().to(device).eval()proc = AutoProcessor.from_pretrained(BASE)for path in [a for a in sys.argv[1:] if not a.startswith("--") and a != ADAPTER]: msgs = [{"role": "user", "content": [{"type": "image", "image": load(path)}, {"type": "text", "text": PROMPT}]}] b = proc.apply_chat_template(msgs, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt").to(device) t = time.time() with torch.no_grad(): g = model.generate(**b, max_new_tokens=80, do_sample=False) text = proc.batch_decode(g[:, b["input_ids"].shape[1]:], skip_special_tokens=True)[0].strip() print(f"{path}: {text} ({time.time() - t:.2f} s)")12345torchtransformers>=4.57peft>=0.17pillowaccelerate.gitattributes+1
README.mdAdded+90
adapter_config.jsonAdded+48
adapter_model.safetensorsAdded+3
examples/spine-hebrew.jpgAdded

examples/spine-latin.jpgAdded

Large File Pointer Details
- SHA256: 884e06a6463fdd5444abba8ee06d6d5ac08e78163246514debc4a351e87159dd
- Pointer size: 131 Bytes
- Size of remote file: 152 kB
read_spine.pyAdded+41
requirements.txtAdded+5