File size: 1,764 Bytes
016ddea b973ef4 016ddea b973ef4 016ddea b973ef4 016ddea b973ef4 016ddea b973ef4 016ddea b973ef4 016ddea b973ef4 016ddea b973ef4 016ddea b973ef4 016ddea b973ef4 016ddea b973ef4 016ddea b973ef4 016ddea b973ef4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
---
library_name: transformers
tags:
- medical
language:
- en
pipeline_tag: visual-question-answering
base_model: microsoft/Florence-2-base-ft
base_model_relation: finetune
---
# 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
```python
! pip install -q "flash_attn==2.6.3" "timm==1.0.8" "einops==0.8.0" "transformers==4.44.0"
```
```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_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)
```
```python
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%
|