Saltar al contenido
ModelPublicadoExterno
Descargar

Florence 2 FT VQA

The Florence-2FTVQA model is a fine-tuned version of the microsoft/Florence-2-base-ft model, tailored specifically for the task of visual question answering.

TipoText modelModelo basemicrosoft/Florence-2-base-ftVersiónFP32Bcalidad

Fuente del modelo

Tipo
Text model
Tamaño del archivo
1,01 GB
Modelo base
microsoft/Florence-2-base-ft
Versión
vFP32
Actualizado
30 oct 2026
Descargas
18
Fuente
Hugging Face

Descripción de la fuente

Model Description

The Florence-2_FT_VQA model is a fine-tuned version of the microsoft/Florence-2-base-ft model, tailored specifically for the task of visual question answering.

  • Finetuned from model: microsoft/Florence-2-base-ft

How to use

! pip install -q "flash_attn==2.7.4.post1" "timm==1.0.15" "einops==0.8.1" "transformers==4.51.3"
from transformers import AutoModelForCausalLM, AutoProcessor
import requests
import torch
from PIL import Image
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("nirusanan/Florence-2_FT_VQA", torch_dtype=torch_dtype, trust_remote_code=True).to(device)
processor = AutoProcessor.from_pretrained("nirusanan/Florence-2_FT_VQA", trust_remote_code=True)
prompt = "DocVQA" + "What is the diseases of this leaf?"


url = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRYoDmTW0JLiW2VNGbT0OozJqi3biTszTOQKCnuuvdPuFUzHS6gQwFdCLQi7mmY7hGD150&usqp=CAU"
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")

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=1024,
    do_sample=False,
    num_beams=3
)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]

parsed_answer = processor.post_process_generation(generated_text, task="DocVQA", image_size=(image.width, image.height))

print(parsed_answer)

Fuentes

1 fuente
Hugging FacePrincipalVersión 846edf2680bae787e330c6ce0fd71912f7acea11
huggingface.co/nirusanan/Florence-2_FT_VQA/tree/846edf2680bae787e330c6ce0fd71912f7acea11

Verificado 30 oct

Download files

Artefactos del modelo

1 artefacto

model.safetensors

safetensors · FP32 (tensor header) · 1,01 GB · SHA-256 611a4bc7b679…ab78 · Hugging Face

Download file

Extractos de fuentes

3 extractos

--- library_name: transformers language: - en pipeline_tag: visual-question-answering base_model: microsoft/Florence-2-base-ft base_model_relation: finetune datasets: - HuggingFaceM4/DocumentVQA --- # Model Description The Florence-2_FT_VQA model is a fine-tuned version of the microsoft/Florence-2-base-ft model, tailored specifically for the task of visual question answering. - **Finetuned from model:** microsoft/Florence-2-base-ft ## How to use ```python ! pip install -q "flash_attn==2.7.4.post1" "timm==1.0.15" "einops==0.8.1" "transformers==4.51.3" ``` ```python from transformers import AutoModelForCausalLM, AutoProcessor import requests import torch from PIL import Image ``` ```python device = "cuda:0" if torch.cuda.is_available() else "cpu" torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32 ``` ```python model = AutoModelForCausalLM.from_pretrained("nirusanan/Florence-2_FT_VQA", torch_dtype=torch_dtype, trust_remote_code=True).to(device) processor = AutoProcessor.from_pretrained("nirusanan/Florence-2_FT_VQA", trust_remote_code=True) ``` ```python prompt = "DocVQA" + "What is the diseases of this leaf?" url = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRYoDmTW0JLiW2VNGbT0OozJqi3biTszTOQKCnuuvdPuFUzHS6gQwFdCLQi7mmY7hGD150&usqp=CAU" image = Image.open(requests.get(url, stream=True).raw).convert("RGB") 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=1024, do_sample=False, num_beams=3 ) generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0] parsed_answer = processor.post_process_generation(generated_text, task="DocVQA", image_size=(image.width, image.height)) print(parsed_answer) ```

Source context: 18 downloads · 0 likes · Pipeline visual-question-answering · Library transformers · Repo nirusanan/Florence-2_FT_VQA

Source context: 12 downloads · 0 likes · Pipeline visual-question-answering · Library transformers · Repo nirusanan/Florence-2_FT_VQA