File size: 1,777 Bytes
1780d21 78003e8 1780d21 78003e8 |
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
---
license: cc-by-nc-4.0
---
<!-- markdownlint-disable first-line-h1 -->
<!-- markdownlint-disable html -->
<div align="center">
<h1>
RadZero: Similarity-Based Cross-Attention for Explainable Vision-Language Alignment in Radiology with Zero-Shot Multi-Task Capability
</h1>
</div>
<p align="center">
📝 <a href="" target="_blank">Paper</a> • 🤗 <a href="https://huggingface.co/Deepnoid/RadZero" target="_blank">Hugging Face</a> • 🧩 <a href="" target="_blank">Github</a>
</p>
<div align="center">
</div>
## 🎬 Get Started
```python
# Deepnoid/RadZero/inference.py
import warnings
import torch
from transformers import AutoImageProcessor, AutoModel, AutoTokenizer
from utils import model_inference
# Suppress specific warnings for cleaner logs
warnings.filterwarnings("ignore", category=UserWarning)
def load_model(device, dtype):
tokenizer = AutoTokenizer.from_pretrained("Deepnoid/RadZero")
image_processor = AutoImageProcessor.from_pretrained("Deepnoid/RadZero")
model = AutoModel.from_pretrained(
"Deepnoid/RadZero",
trust_remote_code=True,
torch_dtype=dtype,
device_map=device,
)
models = {
"tokenizer": tokenizer,
"image_processor": image_processor,
"model": model,
}
return models
if __name__ == "__main__":
# Setup constant
device = torch.device("cuda")
dtype = torch.float32
# load models
models = load_model(device, dtype)
# load image
image_path = "cxr_image.jpg"
# inference
similarity_prob, similarity_map = model_inference(
image_path, "There is fibrosis", **models
)
print(similarity_prob)
print(similarity_map.min())
print(similarity_map.max())
print(similarity_map.shape)
```
|