Image-Text-to-Text
Transformers
ONNX
Safetensors
English
medical
chest-xray
radiology
clip
blip
multimodal
cpu
Instructions to use GAD-Research-Lab/MedicalAI-Light-Weight with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use GAD-Research-Lab/MedicalAI-Light-Weight with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="GAD-Research-Lab/MedicalAI-Light-Weight")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("GAD-Research-Lab/MedicalAI-Light-Weight", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use GAD-Research-Lab/MedicalAI-Light-Weight with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "GAD-Research-Lab/MedicalAI-Light-Weight" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "GAD-Research-Lab/MedicalAI-Light-Weight", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/GAD-Research-Lab/MedicalAI-Light-Weight
- SGLang
How to use GAD-Research-Lab/MedicalAI-Light-Weight 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 "GAD-Research-Lab/MedicalAI-Light-Weight" \ --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": "GAD-Research-Lab/MedicalAI-Light-Weight", "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 "GAD-Research-Lab/MedicalAI-Light-Weight" \ --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": "GAD-Research-Lab/MedicalAI-Light-Weight", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use GAD-Research-Lab/MedicalAI-Light-Weight with Docker Model Runner:
docker model run hf.co/GAD-Research-Lab/MedicalAI-Light-Weight
File size: 4,408 Bytes
e93bfbd | 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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | """
Download pre-trained checkpoints so users can skip training from scratch.
Usage:
python download_model.py # interactive menu
python download_model.py --all # download everything
python download_model.py --fusion # fusion model only
python download_model.py --blip-finetuned # fine-tuned BLIP only
"""
import argparse
import os
import sys
from pathlib import Path
BASE_URL = "https://huggingface.co/your-org/medicalai-lightweight/resolve/main"
CHECKPOINT_DIR = Path("./checkpoints")
BLIP_DIR = Path("./blip-xray-finetuned")
ONNX_DIR = CHECKPOINT_DIR / "onnx_full"
def _ensure_dir(path):
path.mkdir(parents=True, exist_ok=True)
def _download_file(url, dest):
import requests
from rich.console import Console
from rich.progress import Progress, BarColumn, DownloadColumn, TextColumn
console = Console()
console.print(f"[cyan]Downloading {url.split('/')[-1]}...[/cyan]")
resp = requests.get(url, stream=True)
resp.raise_for_status()
total = int(resp.headers.get("content-length", 0))
with Progress(
TextColumn("[cyan] Download[/cyan]"),
BarColumn(),
DownloadColumn(),
transient=True,
) as progress:
task = progress.add_task("", total=total)
with open(dest, "wb") as f:
for chunk in resp.iter_content(chunk_size=8192):
f.write(chunk)
progress.update(task, advance=len(chunk))
console.print(f"[green] Saved to {dest}[/green]")
def download_fusion():
_ensure_dir(CHECKPOINT_DIR)
_ensure_dir(ONNX_DIR)
files = [
("fusion_model.pth", CHECKPOINT_DIR / "fusion_model.pth"),
("fusion_full.onnx", ONNX_DIR / "fusion_full.onnx"),
("labels.json", ONNX_DIR / "labels.json"),
]
for fname, dest in files:
url = f"{BASE_URL}/{fname}"
print(f" Would download: {url} -> {dest}")
print()
print("[yellow]Note: Pre-trained checkpoints are not yet hosted.[/yellow]")
print("[yellow]Train locally with: python training.py --mode prepare-data && python training.py --mode train[/yellow]")
print("[yellow]Then export: python quantization.py --mode export-full[/yellow]")
def download_blip():
_ensure_dir(BLIP_DIR)
files = [
"config.json",
"model.safetensors",
"preprocessor_config.json",
"special_tokens_map.json",
"tokenizer.json",
"tokenizer_config.json",
"vocab.txt",
]
for fname in files:
url = f"{BASE_URL}/blip-xray-finetuned/{fname}"
dest = BLIP_DIR / fname
print(f" Would download: {url} -> {dest}")
print()
print("[yellow]Note: Fine-tuned BLIP is not yet hosted.[/yellow]")
print("[yellow]Train locally with: python xray_training.py --mode train[/yellow]")
def main():
parser = argparse.ArgumentParser(description="Download pre-trained models")
parser.add_argument("--all", action="store_true", help="Download everything")
parser.add_argument("--fusion", action="store_true", help="Download fusion model")
parser.add_argument("--blip-finetuned", action="store_true", help="Download fine-tuned BLIP")
args = parser.parse_args()
if not any([args.all, args.fusion, args.blip_finetuned]):
from rich.console import Console
import questionary
console = Console()
console.print("[bold cyan]Download Pre-trained Models[/bold cyan]")
choice = questionary.select(
"What would you like to download?",
choices=[
"Fusion model (Symptom Check) — ONNX + PyTorch",
"Fine-tuned BLIP (Vision captioning)",
"Everything",
"Cancel",
],
).ask()
if choice == "Cancel":
return
if choice == "Fusion model (Symptom Check) — ONNX + PyTorch":
args.fusion = True
elif choice == "Fine-tuned BLIP (Vision captioning)":
args.blip_finetuned = True
else:
args.all = True
try:
import requests
except ImportError:
print("'requests' is required. Install with: pip install requests")
sys.exit(1)
if args.all or args.fusion:
download_fusion()
if args.all or args.blip_finetuned:
download_blip()
if __name__ == "__main__":
main()
|