Downloads · 30 days
52
31% of all-time downloads
lukeingawesome/TILA
TILA is a image feature extraction model from lukeingawesome. Use it for the image feature extraction task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as mit.
Temporal Inversion for Learning Interval Change in Chest X-Rays Accepted at CVPR 2026
Downloads · 30 days
52
31% of all-time downloads
All-time downloads
169
Public
Parameters
161M
643 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors643 MB · 100%
How the weights are stored.
F32161M · 100%
From the Hugging Face model README
Temporal Inversion for Learning Interval Change in Chest X-Rays Accepted at CVPR 2026
TILA is a vision-language framework that uses temporal inversion — reversing image pairs — as a supervisory signal to enhance the sensitivity of temporal vision-language models to directional change in chest X-rays. Given a current and a prior radiograph, TILA can:
The image encoder is based on the BioViL-T architecture (ResNet-50 + Vision Transformer temporal pooler), and the text encoder is CXR-BERT, both fine-tuned with temporal inversion-aware alignment.
pip install torch>=2.0 torchvision>=0.15 timm>=0.9 transformers>=4.30 safetensors>=0.4 pillow opencv-python numpy
import torch
from transformers import AutoModel
# Load from HuggingFace Hub
model = AutoModel.from_pretrained("lukeingawesome/TILA", trust_remote_code=True)
model = model.to("cuda", dtype=torch.bfloat16)
Or load locally:
from model import TILAModel
model = TILAModel.from_pretrained("model.safetensors")
model = model.to("cuda", dtype=torch.bfloat16)
from processor import TILAProcessor
# Processor handles everything: raw image → model-ready tensor
processor = TILAProcessor(dtype=torch.bfloat16, device="cuda")
current = processor("current_cxr.png") # accepts file paths, numpy arrays, or PIL images
previous = processor("previous_cxr.png")
# 128-dim L2-normalized embeddings
embeddings = model.get_embeddings(current, previous)
The processor automatically applies medical image preprocessing (windowing, black padding removal, resize) followed by model transforms (center crop to 448x448, expand to 3 channels). If your images are already preprocessed, skip the medical preprocessing:
processor = TILAProcessor(raw_preprocess=False, dtype=torch.bfloat16, device="cuda")
The embeddings encode both the current image state and the temporal difference from the prior. They can be used for retrieval, similarity search, or as features for downstream tasks.
text_emb = model.encode_text([
"Improved pulmonary edema.",
"Stable pulmonary edema.",
"Worsening pulmonary edema.",
])
# Zero-shot classification via image-text similarity
similarities = embeddings @ text_emb.T # [1, 3]
prediction = similarities.argmax(dim=1) # 0=improving, 1=stable, 2=worsening
result = model.get_interval_change_prediction(current, previous, mode="bestf1")
print(result["probabilities"]) # Raw change probability
print(result["predictions"]) # Binary: 0 = no change, 1 = change
print(result["threshold"]) # Threshold used
Three threshold modes are available:
| 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) |
python inference.py \
--checkpoint model.safetensors \
--current_image /path/to/current.png \
--previous_image /path/to/previous.png
Note: This preprocessing is not applied automatically. Run it as a separate step before model inference.
If your chest X-rays are raw (e.g., DICOM-derived PNGs with varying bit depths, black borders, or 16-bit depth), preprocess them first:
import cv2
from preprocess import preprocess_image
img = preprocess_image("raw_cxr.png")
cv2.imwrite("preprocessed.png", img)
The pipeline applies:
mean +/- 2*std, normalizes to [0, 1]# CLI usage
python preprocess.py --input raw.png --output preprocessed.png
If your images are already preprocessed (contrast-normalized, cropped, resized grayscale PNGs), you can skip this step and feed them directly to the model.
inference.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 |
If you use this model, please cite:
@article{ko2026temporal,
title={Temporal Inversion for Learning Interval Change in Chest X-Rays},
author={Ko, Hanbin and Jeon, Kyeongmin and Choi, Doowoong and Park, Chang Min},
journal={arXiv preprint arXiv:2604.04563},
year={2026}
}
This model builds upon BioViL-T by Microsoft Research:
@inproceedings{bannur2023biovilt,
title={Learning to Exploit Temporal Structure for Biomedical Vision-Language Processing},
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},
booktitle={CVPR},
year={2023}
}
This model is released under the MIT License following BioViL-T.