--- license: cc-by-nc-3.0 pipeline_tag: image-to-text tags: - vision - ocr - trocr - transformers - handwriting-recognition - document-processing --- # Tzefa Word OCR Model (Fine-tuned TrOCR) Fine-tuned TrOCR model for recognizing individual handwritten Tzefa keywords. ## Architecture - **Base model:** `microsoft/trocr-small-stage1` - **Fine-tuned on:** Handwritten Tzefa keywords (uppercase Hebrew programming commands, number words, variable names) - **Framework:** HuggingFace Transformers (`VisionEncoderDecoderModel`) ## Vocabulary Tzefa keywords include: - **Commands:** MAKEINTEGER, MAKESTR, MAKELIST, MAKEBOOL, PRINTINTEGER, PRINTSTR, ADD, SUBTRACT, MULTIPLY, DIVIDE, WHILETRUE, IFTRUE, etc. - **Number words:** ZERO through ONEHUNDRED - **User-defined variable names** ## Usage ```python from transformers import TrOCRProcessor, VisionEncoderDecoderModel from PIL import Image # use_fast=False is required to prevent tokenizer conversion crash processor = TrOCRProcessor.from_pretrained("microsoft/trocr-small-stage1", use_fast=False) model = VisionEncoderDecoderModel.from_pretrained("WARAJA/Tzefa-Word-OCR-TrOCR") image = Image.open("word_crop.png").convert("RGB") pixel_values = processor(image, return_tensors="pt").pixel_values generated_ids = model.generate(pixel_values) text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0] print(text) ``` ## Related - [Full Tzefa Pipeline](https://huggingface.co/spaces/WARAJA/Tzefa) - [OCR Demo](https://huggingface.co/spaces/WARAJA/Tzefa-OCR) - [Word OCR Dataset](https://huggingface.co/datasets/WARAJA/Tzefa-Word-OCR-Dataset)