Text Generation
Transformers
Safetensors
English
cxrmate-ed
chest X-ray report generation
radiology report generation
image captioning
chest X-ray
X-ray
radiology
cxrmate
report
radiology report
multimodal
patient data
patient records
mimic-cxr
mimic-iv-ed
custom_code
Instructions to use aehrc/cxrmate-ed with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aehrc/cxrmate-ed with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="aehrc/cxrmate-ed", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("aehrc/cxrmate-ed", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use aehrc/cxrmate-ed with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "aehrc/cxrmate-ed" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aehrc/cxrmate-ed", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/aehrc/cxrmate-ed
- SGLang
How to use aehrc/cxrmate-ed with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "aehrc/cxrmate-ed" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aehrc/cxrmate-ed", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "aehrc/cxrmate-ed" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aehrc/cxrmate-ed", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use aehrc/cxrmate-ed with Docker Model Runner:
docker model run hf.co/aehrc/cxrmate-ed
Download utils.py from aehrc/cxrmate-ed: direct link, hf CLI and curl.
- Browser
- Download file 981 Bytes
-
https://huggingface.co/aehrc/cxrmate-ed/resolve/main/utils.py
- Command line
-
hf download hf://aehrc/cxrmate-ed/utils.py
-
curl -L -o utils.py https://huggingface.co/aehrc/cxrmate-ed/resolve/main/utils.py
981 Bytes
| import torch | |
| def compute_time_delta(event_time, reference_time, time_delta_map, denominator = 3600, to_tensor=True): | |
| """ | |
| How to we transform time delta inputs? It appears that minutes are used as the input to | |
| a weight matrix in "Self-Supervised Transformer for Sparse and Irregularly Sampled Multivariate | |
| Clinical Time-Series". This is almost confirmed by the CVE class defined here: | |
| https://github.com/sindhura97/STraTS/blob/main/strats_notebook.ipynb, where the input has | |
| a size of one. | |
| """ | |
| time_delta = reference_time - event_time | |
| time_delta = time_delta.total_seconds() / (denominator) | |
| assert isinstance(time_delta, float), f'time_delta should be float, not {type(time_delta)}.' | |
| if time_delta < 0: | |
| raise ValueError(f'time_delta should be greater than or equal to zero, not {time_delta}.') | |
| time_delta = time_delta_map(time_delta) | |
| if to_tensor: | |
| time_delta = torch.tensor(time_delta) | |
| return time_delta | |