Files changed (1) hide show
  1. README.md +6 -4
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 AutoModel, AutoProcessor
35
 
36
  # Load model and processor
37
  model_id = "RioJune/AG-KD"
38
- model = AutoModel.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
  # Example instruction for abnormality grounding
46
- # The model expects instructions to start with specific tokens like <OD> for object detection.
47
- instruction = "<OD> Please localize the lesion. "
 
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")