Safetensors
custom_code
jonggwon-park commited on
Commit
78003e8
·
1 Parent(s): 5718512

update README

Browse files
Files changed (1) hide show
  1. README.md +75 -2
README.md CHANGED
@@ -1,5 +1,78 @@
1
  ---
2
- library_name: transformers
3
- license: cc-by-4.0
4
  ---
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: cc-by-nc-4.0
 
3
  ---
4
 
5
+ <!-- markdownlint-disable first-line-h1 -->
6
+ <!-- markdownlint-disable html -->
7
+
8
+ <div align="center">
9
+ <h1>
10
+ RadZero: Similarity-Based Cross-Attention for Explainable Vision-Language Alignment in Radiology with Zero-Shot Multi-Task Capability
11
+ </h1>
12
+ </div>
13
+
14
+ <p align="center">
15
+ 📝 <a href="" target="_blank">Paper</a> • 🤗 <a href="https://huggingface.co/Deepnoid/RadZero" target="_blank">Hugging Face</a> • 🧩 <a href="" target="_blank">Github</a>
16
+ </p>
17
+
18
+ <div align="center">
19
+ </div>
20
+
21
+
22
+ ## 🎬 Get Started
23
+
24
+ ```python
25
+ # Deepnoid/RadZero/inference.py
26
+ import warnings
27
+
28
+ import torch
29
+ from transformers import AutoImageProcessor, AutoModel, AutoTokenizer
30
+
31
+ from utils import model_inference
32
+
33
+ # Suppress specific warnings for cleaner logs
34
+ warnings.filterwarnings("ignore", category=UserWarning)
35
+
36
+
37
+ def load_model(device, dtype):
38
+
39
+ tokenizer = AutoTokenizer.from_pretrained("Deepnoid/RadZero")
40
+ image_processor = AutoImageProcessor.from_pretrained("Deepnoid/RadZero")
41
+
42
+ model = AutoModel.from_pretrained(
43
+ "Deepnoid/RadZero",
44
+ trust_remote_code=True,
45
+ torch_dtype=dtype,
46
+ device_map=device,
47
+ )
48
+
49
+ models = {
50
+ "tokenizer": tokenizer,
51
+ "image_processor": image_processor,
52
+ "model": model,
53
+ }
54
+ return models
55
+
56
+
57
+ if __name__ == "__main__":
58
+ # Setup constant
59
+ device = torch.device("cuda")
60
+ dtype = torch.float32
61
+
62
+ # load models
63
+ models = load_model(device, dtype)
64
+
65
+ # load image
66
+ image_path = "cxr_image.jpg"
67
+
68
+ # inference
69
+ similarity_prob, similarity_map = model_inference(
70
+ image_path, "There is fibrosis", **models
71
+ )
72
+
73
+ print(similarity_prob)
74
+ print(similarity_map.min())
75
+ print(similarity_map.max())
76
+ print(similarity_map.shape)
77
+ ```
78
+