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.
Modellquelle
- Art
- Text model
- Dateigröße
- 1,01 GB
- Basismodell
- microsoft/Florence-2-base-ft
- Version
- vFP32
- Aktualisiert
- 30. Okt. 2026
- Downloads
- 18
- Quelle
- Hugging Face
Quellenbeschreibung
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)
Quellen
1 Quelle
Quellen
1 QuelleVerifiziert 30. Okt.
Download files
Repository files
File inventory only; completeness is unverified.
Modellartefakte
1 Artefakt
Modellartefakte
1 Artefaktmodel.safetensors
safetensors · FP32 (tensor header) · 1,01 GB · SHA-256 611a4bc7b679…ab78 · Hugging Face
Download fileQuellenauszüge
3 Auszüge
Quellenauszüge
3 Auszüge--- 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
