Saltar al contenido
ModelPublicadoExterno
Descargar

Idefics2 OCR

Finetuned of Idefics2-8b with fp16 weight update on nielsr/docvqa1200examplesdonut dataset for document VQA pairs.

TipoLoRAVersiónFP32Unratedcalidad

Fuente del modelo

Tipo
LoRA
Tamaño del archivo
89,1 MB
Versión
vFP32
Actualizado
5 nov 2026
Descargas
0
Fuente
Hugging Face

Descripción de la fuente

IDEFICS2-OCR

Finetuned of Idefics2-8b with fp16 weight update on nielsr/docvqa_1200_examples_donut dataset for document VQA pairs.

Usage

from transformers import BitsAndBytesConfig, AutoModelForVision2Seq, AutoProcessor
from transformers.image_utils import load_image

processor = AutoProcessor.from_pretrained("smishr-18/Idefics2-OCR", do_image_splitting=False)

bnb_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dtype=torch.float16
)

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
model = AutoModelForVision2Seq.from_pretrained(
    "smishr-18/Idefics2-OCR",
    quantization_config=bnb_config,
    device_map=device,
    low_cpu_mem_usage=True
    )

image = load_image("https://images.pokemontcg.io/pl1/1_hires.png")

messages = [
    {
        "role": "user",
        "content": [
            {"type": "text", "text": "Explain."},
            {"type": "image"},
            {"type": "text", "text": "What is the reflex energy in the image?"}
        ]
    }
]

text = processor.apply_chat_template(messages, add_generation_prompt=True)
inputs = processor(text=[text.strip()], images=[image4], return_tensors="pt", padding=True)
inputs = {k: v.to(device) for k, v in inputs.items()}

# Generate texts
generated_ids = model.generate(**inputs, max_new_tokens=500)
generated_texts = processor.batch_decode(generated_ids, skip_special_tokens=True)
print(generated_texts)
# The reflex energy in the image is 70.

Limitations

The model was finetuned on limited T4 GPU and could be fintuned with more adapters on devices with torch.cuda.get_device_capability()[0] >= 8 or Ampere GPUs.

  • Developed by: Shubh Mishra, Aug 2024
  • Model Type: VLM
  • Language(s) (NLP): English
  • License: MIT
  • Finetuned from model: HuggingFaceM4/idefics2-8b

Fuentes

1 fuente
Hugging FacePrincipalVersión eff144c7a4a139472866517920065b714b56856f
huggingface.co/smishr-18/Idefics2-OCR/tree/eff144c7a4a139472866517920065b714b56856f

Verificado 5 nov

Download files

Artefactos del modelo

1 artefacto

adapter_model.safetensors

safetensors · FP32 (tensor header) · 89,1 MB · SHA-256 c4efec4a3fac…c04c · Hugging Face

Download file

Extractos de fuentes

2 extractos

--- license: mit datasets: - nielsr/docvqa_1200_examples_donut language: - en library_name: transformers pipeline_tag: visual-question-answering --- ### IDEFICS2-OCR Finetuned of Idefics2-8b with fp16 weight update on nielsr/docvqa_1200_examples_donut dataset for document VQA pairs. ## Usage ```Python from transformers import BitsAndBytesConfig, AutoModelForVision2Seq, AutoProcessor from transformers.image_utils import load_image processor = AutoProcessor.from_pretrained("smishr-18/Idefics2-OCR", do_image_splitting=False) bnb_config = BitsAndBytesConfig( load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.float16 ) device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") model = AutoModelForVision2Seq.from_pretrained( "smishr-18/Idefics2-OCR", quantization_config=bnb_config, device_map=device, low_cpu_mem_usage=True ) image = load_image("https://images.pokemontcg.io/pl1/1_hires.png") messages = [ { "role": "user", "content": [ {"type": "text", "text": "Explain."}, {"type": "image"}, {"type": "text", "text": "What is the reflex energy in the image?"} ] } ] text = processor.apply_chat_template(messages, add_generation_prompt=True) inputs = processor(text=[text.strip()], images=[image4], return_tensors="pt", padding=True) inputs = {k: v.to(device) for k, v in inputs.items()} # Generate texts generated_ids = model.generate(**inputs, max_new_tokens=500) generated_texts = processor.batch_decode(generated_ids, skip_special_tokens=True) print(generated_texts) # The reflex energy in the image is 70. ``` ## Limitations The model was finetuned on limited T4 GPU and could be fintuned with more adapters on devices with ```torch.cuda.get_device_capability()[0] >= 8``` or Ampere GPUs. - **Developed by:** Shubh Mishra, Aug 2024 - **Model Type:** VLM - **Language(s) (NLP):** English - **License:** MIT - **Finetuned from model:** HuggingFaceM4/idefics2-8b

Source context: 0 downloads · 0 likes · Pipeline visual-question-answering · Library transformers · Repo smishr-18/Idefics2-OCR