Skip to content

Quick fun with transfer learning for Retina Disease Classification

License

Notifications You must be signed in to change notification settings

torchgreedy/PretrainedOnRetina

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Retina Disease Classification – FastAPI Inference Server

This repository provides a minimal FastAPI server to deploy your trained ViT model for retina OCT disease classification.

Prepare the model

After training in your notebook/script, save artifacts to a directory, for example my-trained-vit-model/:

model.save_pretrained('my-trained-vit-model')
processor.save_pretrained('my-trained-vit-model')

Ensure the directory contains files like config.json, pytorch_model.bin (or safetensors), preprocessor_config.json, etc.

Install

python -m venv .venv
. .venv/Scripts/activate  # Windows PowerShell: .venv\Scripts\Activate.ps1
pip install -r requirements.txt

Run the API

set MODEL_DIR=my-trained-vit-model  # Windows
uvicorn app.main:app --host 0.0.0.0 --port 8000

Open http://127.0.0.1:8000 to use the simple HTML upload form.

Health check:

curl http://127.0.0.1:8000/health

Predict with cURL:

curl -X POST "http://127.0.0.1:8000/predict?top_k=3" \
  -H "Content-Type: multipart/form-data" \
  -F "file=@sample.jpg"

Sample JSON response:

{
  "predictions": [
    {"label": "CNV", "score": 0.91},
    {"label": "DME", "score": 0.06},
    {"label": "DRUSEN", "score": 0.02}
  ]
}

Notes

  • The server reads MODEL_DIR env var; defaults to my-trained-vit-model in the repo root.
  • CPU inference by default. If you want GPU, move tensors to CUDA and ensure PyTorch with CUDA is installed.

About

Quick fun with transfer learning for Retina Disease Classification

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages