Downloads · 30 days
6
11% of all-time downloads
riphunter7001x/PaliGemma3_FT_OCR
PaliGemma3_FT_OCR is a machine learning model from riphunter7001x. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as gemma.
should probably proofread and complete it, then remove this comment. --
Downloads · 30 days
6
11% of all-time downloads
All-time downloads
57
Public
Repo size
45.3 MB
Likes
0
Public
Click a slice to open those files.
.safetensors45.3 MB · 100%
From the Hugging Face model README
This model is a fine-tuned version of google/paligemma-3b-pt-448 on an unknown dataset.
More information needed
More information needed
More information needed
The following hyperparameters were used during training:
from transformers import AutoProcessor, PaliGemmaForConditionalGeneration
from PIL import Image
import torch
import json
# Load model and processor
model_id = "google/paligemma-3b-pt-448"
peft_adapter_id = "riphunter7001x/PaliGemma3_FT_OCR"
model = PaliGemmaForConditionalGeneration.from_pretrained(model_id, device_map="auto")
processor = AutoProcessor.from_pretrained(model_id)
model.load_adapter(peft_adapter_id).eval()
TORCH_DTYPE = model.dtype
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Load and process image
image = Image.open("image.jpg")
prefix = "<image>extract Document data in JSON format"
inputs = processor(
text=prefix,
images=image,
return_tensors="pt"
).to(TORCH_DTYPE).to(DEVICE)
prefix_length = inputs["input_ids"].shape[-1]
with torch.inference_mode():
generation = model.generate(**inputs, max_new_tokens=512, do_sample=False)
generation = generation[0][prefix_length:]
decoded = processor.decode(generation, skip_special_tokens=True)
print(json.dumps(json.loads(decoded), indent=4))
This code loads the fine-tuned PaliGemma model, processes an input image, and extracts document data in JSON format.