Model Card for Model ID

Model Details

Model Description

This is the model card of a ๐Ÿค— transformers model that has been pushed on the Hub. This model card has been automatically generated.

  • Developed by: Aniket Maurya
  • Model type: Visual language model
  • License: MIT
  • Finetuned from model [optional]: microsoft/Florence-2-base-ft

Uses

Use this model for extracting total amount from a receipt.

How to Get Started with the Model

Use the code below to get started with the model.

import requests

from PIL import Image
from transformers import AutoProcessor, AutoModelForCausalLM 

device = "cuda:0" if torch.cuda.is_available() else "cpu"
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32

model = AutoModelForCausalLM.from_pretrained("aniketmaurya/receipt-model-2025", torch_dtype=torch_dtype, trust_remote_code=True).to(device)
processor = AutoProcessor.from_pretrained("microsoft/Florence-2-base-ft", trust_remote_code=True)

prompt = "<VQA>Given the following receipt, extract the total amount spent."

url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
image = Image.open(requests.get(url, stream=True).raw)

inputs = processor(text=prompt, images=image, return_tensors="pt").to(device, torch_dtype)

generated_ids = model.generate(
    input_ids=inputs["input_ids"],
    pixel_values=inputs["pixel_values"],
    max_new_tokens=100,
    do_sample=False,
    num_beams=3
)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]

print(generated_text)

Training Details

Training Data

Public receipt data comprising 216 images forked from Roboflow universe and annotated manually for total amount.

Training Procedure

Training configuration

{
    'model_id': 'microsoft/Florence-2-base-ft',
    'revision': 'refs/pr/20',
    'epochs': 30,
    'optimizer': 'adamw',
    'lr': 5e-06,
    'lr_scheduler': 'linear',
    'batch_size': 8,
    'val_batch_size': None,
    'num_workers': 0,
    'val_num_workers': None,
    'lora_r': 8,
    'lora_alpha': 8,
    'lora_dropout': 0.05,
    'bias': 'none',
    'use_rslora': True,
    'init_lora_weights': 'gaussian',
}

Preprocessing [optional]

Image augmentations:

  • shear, random rotate, and noise

Evaluation

Vibe check ๐Ÿ˜Ž

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model is not currently available via any of the supported third-party Inference Providers, and the model is not deployed on the HF Inference API.

Model tree for aniketmaurya/receipt-model-2025

Finetuned
(17)
this model