Downloads · 30 days
1
25% of all-time downloads
abhisheksinghrathore/Finetuned-Llava
Finetuned-Llava is a machine learning model from abhisheksinghrathore. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This repository hosts the fine-tuned LLAVA model files, which have been adapted for data parsing and extracting JSON information from image reciepts. The model was fine-tuned on cord-v2 dataset.
Downloads · 30 days
1
25% of all-time downloads
All-time downloads
4
Public
Repo size
88.7 MB
Likes
0
Public
Click a slice to open those files.
.safetensors88.7 MB · 98%
From the Hugging Face model README
This repository hosts the fine-tuned LLAVA model files, which have been adapted for data parsing and extracting JSON information from image reciepts. The model was fine-tuned on cord-v2 dataset.
You can load and use this model directly from the HuggingFace Hub with the transformers library. Below is an example of how to load the model:
from transformers import AutoProcessor, BitsAndBytesConfig, LlavaNextForConditionalGeneration
MODEL_ID = "llava-hf/llava-v1.6-mistral-7b-hf"
REPO_ID = "abhisheksinghrathore/Finetuned-Llava"
processor = AutoProcessor.from_pretrained(MODEL_ID)
quantization_config = BitsAndBytesConfig(
load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.float16
)
model = LlavaNextForConditionalGeneration.from_pretrained(
REPO_ID,
torch_dtype=torch.float16,
quantization_config=quantization_config,
)
image = Image.open(io.BytesIO(image_bytes))
# Prepare input
prompt = f"[INST] <image>\nExtract JSON [/INST]"
max_output_token = 256
inputs = processor(prompt, image, return_tensors="pt").to("cuda:0")
output = model.generate(**inputs, max_new_tokens=max_output_token)
response = processor.decode(output[0], skip_special_tokens=True)
# Convert response to JSON
generated_json = token2json(response)