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
| """ | |
| 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() | |