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.
Fonte do modelo
- Tipo
- Text model
- Tamanho do arquivo
- 1,01 GB
- Modelo base
- microsoft/Florence-2-base-ft
- Versão
- vFP32
- Atualizado
- 30 de out. de 2026
- Downloads
- 18
- Fonte
- Hugging Face
Descrição da fonte
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)
Fontes
1 fonte
Fontes
1 fonteVerificado 30 de out.
Download files
Repository files
File inventory only; completeness is unverified.
Artefatos de modelo
1 artefato
Artefatos de modelo
1 artefatomodel.safetensors
safetensors · FP32 (tensor header) · 1,01 GB · SHA-256 611a4bc7b679…ab78 · Hugging Face
Download fileTrechos de fonte
3 trechos
Trechos de fonte
3 trechos--- 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
