Views
No views yet
pip install torch>=2.0 torchvision>=0.15 timm>=0.9 transformers>=4.30 safetensors>=0.4 pillow opencv-python numpy1import torch
2from transformers import AutoModel
3
4# Load from HuggingFace Hub
5model = AutoModel.from_pretrained("lukeingawesome/TILA", trust_remote_code=True)
6model = model.to("cuda", dtype=torch.bfloat16)1from model import TILAModel
2model = TILAModel.from_pretrained("model.safetensors")
3model = model.to("cuda", dtype=torch.bfloat16)1from processor import TILAProcessor
2
3# Processor handles everything: raw image → model-ready tensor
4processor = TILAProcessor(dtype=torch.bfloat16, device="cuda")1current = processor("current_cxr.png") # accepts file paths, numpy arrays, or PIL images
2previous = processor("previous_cxr.png")
3
4# 128-dim L2-normalized embeddings
5embeddings = model.get_embeddings(current, previous)processor = TILAProcessor(raw_preprocess=False, dtype=torch.bfloat16, device="cuda")1text_emb = model.encode_text([
2 "Improved pulmonary edema.",
3 "Stable pulmonary edema.",
4 "Worsening pulmonary edema.",
5])
6
7# Zero-shot classification via image-text similarity
8similarities = embeddings @ text_emb.T # [1, 3]
9prediction = similarities.argmax(dim=1) # 0=improving, 1=stable, 2=worsening1result = model.get_interval_change_prediction(current, previous, mode="bestf1")
2
3print(result["probabilities"]) # Raw change probability
4print(result["predictions"]) # Binary: 0 = no change, 1 = change
5print(result["threshold"]) # Threshold used| Mode | Threshold | Description |
|---|---|---|
"bestf1" | 0.29 | Maximizes F1 score (balanced sensitivity/specificity) |
"default" | 0.50 | Standard sigmoid cutoff |
"spec95" | 0.64 | Targets 95% specificity (conservative, fewer false positives) |
1python inference.py \
2 --checkpoint model.safetensors \
3 --current_image /path/to/current.png \
4 --previous_image /path/to/previous.pngNote: This preprocessing is not applied automatically. Run it as a separate step before model inference.
1import cv2
2from preprocess import preprocess_image
3
4img = preprocess_image("raw_cxr.png")
5cv2.imwrite("preprocessed.png", img)mean +/- 2*std, normalizes to [0, 1]1# CLI usage
2python preprocess.py --input raw.png --output preprocessed.pnginference.py)torch.bfloat16 recommended on GPU, torch.float32 on CPU| File | Description |
|---|---|
model.safetensors | Model weights (613 MB, image + text + classifier) |
config.json | Model configuration (for AutoModel support) |
configuration_tila.py | TILAConfig class |
model.py | Self-contained model architecture |
processor.py | Image processor (raw image → model-ready tensor) |
preprocess.py | Medical image preprocessing utilities |
inference.py | Example inference script |
1@article{ko2026temporal,
2 title={Temporal Inversion for Learning Interval Change in Chest X-Rays},
3 author={Ko, Hanbin and Jeon, Kyeongmin and Choi, Doowoong and Park, Chang Min},
4 journal={arXiv preprint arXiv:2604.04563},
5 year={2026}
6}1@inproceedings{bannur2023biovilt,
2 title={Learning to Exploit Temporal Structure for Biomedical Vision-Language Processing},
3 author={Bannur, Shruthi and Hyland, Stephanie and Liu, Qianchu and Perez-Garcia, Fernando and Oktay, Ozan and Naumann, Tristan and Nori, Aditya and Alvarez-Valle, Javier},
4 booktitle={CVPR},
5 year={2023}
6}