Model Description
The Florence-2_FT_Lung-Cancer-detection model is a fine-tuned version of the microsoft/Florence-2-base-ft model, tailored specifically for the task of lung cancer detection using lung images.
- Developed by: Nirusanan
- License:
- Finetuned from model: microsoft/Florence-2-base-ft
How to use
! pip install -q "flash_attn==2.6.3" "timm==1.0.8" "einops==0.8.0" "transformers==4.44.0"
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_Lung-Cancer-detection", torch_dtype=torch_dtype, trust_remote_code=True).to(device)
processor = AutoProcessor.from_pretrained("nirusanan/Florence-2_FT_Lung-Cancer-detection", trust_remote_code=True)
prompt = "<DocVQA>" + "What is the type of lung cancer?"
url = "https://www.uab.edu/news/images/ct_scan.jpg"
image = Image.open(requests.get(url, stream=True).raw)
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)
Evaluation
Test Accuracy: 99.17%
- Downloads last month
- 18
Inference API (serverless) does not yet support model repos that contain custom code.
Model tree for nirusanan/Florence-2_FT_Lung-Cancer-detection
Base model
microsoft/Florence-2-base-ft