Views
No views yet
pip install unsloth transformers torch pillow1from unsloth import FastVisionModel
2import torch
3from transformers import AutoModel
4import os
5
6os.environ["UNSLOTH_WARN_UNINITIALIZED"] = '0'
7
8# Load the model
9model, tokenizer = FastVisionModel.from_pretrained(
10 "karankulshrestha/formula_ocr",
11 load_in_4bit = False,
12 auto_model = AutoModel,
13 trust_remote_code = True,
14 unsloth_force_compile = True,
15 use_gradient_checkpointing = "unsloth",
16)
17
18# Enable fast inference
19FastVisionModel.for_inference(model)
20
21# Run OCR on an image
22result = model.infer(
23 tokenizer,
24 prompt="\nFree OCR.",
25 image_file="path/to/your/image.jpg",
26 output_path="./output",
27 base_size=1024,
28 image_size=640,
29 crop_mode=True,
30 save_results=True,
31)
32
33print("OCR Result:", result)
1@misc{formula_ocr},
2 author = {Karan Kulshrestha},
3 title = {Hand-written OCR Model},
4 year = {2025},
5 publisher = {HuggingFace},
6 url = {https://huggingface.co/karankulshrestha/formula_ocr}
7}