Fixed README.md
#4
by
shantam00
- opened
README.md
CHANGED
|
@@ -31,20 +31,22 @@ Here's a basic example of how to use the model for abnormality grounding:
|
|
| 31 |
```python
|
| 32 |
import torch
|
| 33 |
from PIL import Image
|
| 34 |
-
from transformers import
|
| 35 |
|
| 36 |
# Load model and processor
|
| 37 |
model_id = "RioJune/AG-KD"
|
| 38 |
-
model =
|
| 39 |
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
|
| 40 |
|
| 41 |
# Example image (replace with your medical image path)
|
| 42 |
# Ensure 'your_medical_image.png' exists in your directory or provide a full path.
|
| 43 |
image = Image.open("path/to/your/medical_image.png").convert("RGB")
|
| 44 |
|
|
|
|
| 45 |
# Example instruction for abnormality grounding
|
| 46 |
-
|
| 47 |
-
|
|
|
|
| 48 |
|
| 49 |
# Prepare inputs
|
| 50 |
inputs = processor(images=image, text=instruction, return_tensors="pt")
|
|
|
|
| 31 |
```python
|
| 32 |
import torch
|
| 33 |
from PIL import Image
|
| 34 |
+
from transformers import AutoModelForCausalLM, AutoProcessor
|
| 35 |
|
| 36 |
# Load model and processor
|
| 37 |
model_id = "RioJune/AG-KD"
|
| 38 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True)
|
| 39 |
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
|
| 40 |
|
| 41 |
# Example image (replace with your medical image path)
|
| 42 |
# Ensure 'your_medical_image.png' exists in your directory or provide a full path.
|
| 43 |
image = Image.open("path/to/your/medical_image.png").convert("RGB")
|
| 44 |
|
| 45 |
+
# The model expects instructions to start with specific tokens such as <OD>, <CAPTION_FOR_PHRASE_GROUNDING> and <CAPTION>, depending on the task.
|
| 46 |
# Example instruction for abnormality grounding
|
| 47 |
+
target = "pulmonary fibrosis"
|
| 48 |
+
definition = "Scarring of the lung tissue creating a dense fibrous appearance."
|
| 49 |
+
instruction = f"<CAPTION_TO_PHRASE_GROUNDING>Locate the phrases in the caption: {target} means {definition}."
|
| 50 |
|
| 51 |
# Prepare inputs
|
| 52 |
inputs = processor(images=image, text=instruction, return_tensors="pt")
|