Delete README
Browse files
README
DELETED
|
@@ -1,68 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
language:
|
| 4 |
-
- en
|
| 5 |
-
library_name: pytorch
|
| 6 |
-
pipeline_tag: image-to-text
|
| 7 |
-
tags:
|
| 8 |
-
- ocr
|
| 9 |
-
- scene-text-recognition
|
| 10 |
-
- craft
|
| 11 |
-
- crnn
|
| 12 |
-
- food-labels
|
| 13 |
-
---
|
| 14 |
-
|
| 15 |
-
# Ingredient Reader: OCR weights for food ingredient labels
|
| 16 |
-
|
| 17 |
-
These are the weights behind [Ingredient Reader](https://ingredient-reader.streamlit.app), which reads the ingredient list on a food label from a photo. They come from the undergraduate thesis *Pengembangan Sistem OCR Berbasis CRAFT dan CRNN untuk Pengenalan Teks Daftar Bahan pada Label Makanan* by Rakeen Aria Alireza. The code is at [github.com/rakeenaria/food-ingredient-ocr-craft-crnn](https://github.com/rakeenaria/food-ingredient-ocr-craft-crnn).
|
| 18 |
-
|
| 19 |
-
## Files
|
| 20 |
-
|
| 21 |
-
| File | What it is | SHA-256 |
|
| 22 |
-
|---|---|---|
|
| 23 |
-
| `best_accuracy.pth` | Word recognizer: CRNN (TPS-ResNet-BiLSTM-Attn) fine-tuned on food-label word images (run `FT_801010_off`) | `405389e61a024a1d807b6438d3add77e1a50735da42cbbedafc72a34200710a6` |
|
| 24 |
-
| `opt.txt` | The recognizer's training settings: case-sensitive characters, grayscale 32 × 100 input, no PAD, maximum length 60 | `63540fcee6c9a2e01bcb88276f3aaf7ff5bee48b5dacffe7cc7402eba3d7c330` |
|
| 25 |
-
| `craft_mlt_25k.pth` | Text detector: CRAFT, the original pretrained weights from Clova AI, unchanged | `4a5efbfb48b4081100544e75e1e2b57f8de3d84f213004b14b85fd4b3748db17` |
|
| 26 |
-
|
| 27 |
-
## Results
|
| 28 |
-
|
| 29 |
-
These are the thesis results.
|
| 30 |
-
|
| 31 |
-
- **Test split, word images:** 94.693% word accuracy, CER 0.015, WER 0.053. The split holds 10% of 6,081 curated word images (80:10:10).
|
| 32 |
-
- **The same split before fine-tuning:** 90.381%, using the pretrained `TPS-ResNet-BiLSTM-Attn-case-sensitive`.
|
| 33 |
-
- **Five real product photos, end to end (detection and recognition):** 92.248% word accuracy.
|
| 34 |
-
|
| 35 |
-
## Usage
|
| 36 |
-
|
| 37 |
-
Clone the GitHub repository and run this from its root:
|
| 38 |
-
|
| 39 |
-
```python
|
| 40 |
-
import cv2
|
| 41 |
-
from huggingface_hub import hf_hub_download
|
| 42 |
-
|
| 43 |
-
from src.ocr_engine import OCREngine
|
| 44 |
-
|
| 45 |
-
repo = "rakeenaria/ingredient-reader"
|
| 46 |
-
recognizer = hf_hub_download(repo, "best_accuracy.pth")
|
| 47 |
-
hf_hub_download(repo, "opt.txt") # settings, read next to the checkpoint
|
| 48 |
-
detector = hf_hub_download(repo, "craft_mlt_25k.pth")
|
| 49 |
-
|
| 50 |
-
engine = OCREngine(recognizer, detector)
|
| 51 |
-
result = engine.process(cv2.imread("label.jpg"))
|
| 52 |
-
print(result.text)
|
| 53 |
-
```
|
| 54 |
-
|
| 55 |
-
## Training data
|
| 56 |
-
|
| 57 |
-
The recognizer was fine-tuned on word crops from the Kaggle dataset *Ingredients Image from Food Label*. The crops were curated into 6,081 word images.
|
| 58 |
-
|
| 59 |
-
## Limitations
|
| 60 |
-
|
| 61 |
-
- Printed English ingredient lists only. Handwriting and other languages are not supported.
|
| 62 |
-
- Small, blurry, glossy or curved text lowers accuracy.
|
| 63 |
-
- OCR can be wrong. Always check the physical label, especially if you have an allergy.
|
| 64 |
-
|
| 65 |
-
## Credits and licenses
|
| 66 |
-
|
| 67 |
-
- **Recognizer:** the architecture, the training code and the pretrained starting point come from [deep-text-recognition-benchmark](https://github.com/clovaai/deep-text-recognition-benchmark) by Clova AI Research, NAVER (Apache 2.0).
|
| 68 |
-
- **Detector:** [CRAFT](https://github.com/clovaai/CRAFT-pytorch) by Clova AI Research, NAVER (MIT). The weights are unchanged.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|