CoolFace
Apppublic

Sandahk/medical-simulator-demo

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

Medical Simulator Demo

A simple demo project combining FastAPI (backend) and a small HTML/CSS/JS frontend to simulate CT-slice phase processing (arterial vs venous). ---

πŸš€ Features

  • β€”Upload a CT-slice image (.jpg / .png)
  • β€”Simulate arterial phase (contrast + sharpening)
  • β€”Simulate venous phase (smoothing / blur)
  • β€”Preview original (left) and processed (right) images
  • β€”Status messages with icons (⏳ processing, βœ… done, ⚠️ error)
  • β€”Download processed results (Not requested - Extra feature)

🐳 Run with Docker (If you have docker installed)

bash
docker compose up --build

πŸ‘‰ Open http://127.0.0.1:7860

This setup mounts your local files (backend/, frontend/, main.py) into the container, so changes are reflected instantly without rebuilding.


πŸ› οΈ Run locally (Python)

Recommended: use Python 3.11 for easiest setup (avoids Pillow build issues on macOS).

bash
# create and activate venv
python -m venv venv
# Windows
venv\Scripts\activate
# Linux/Mac
source venv/bin/activate

# install dependencies
pip install -r requirements.txt

# run FastAPI server
python main.py

πŸ‘‰ Open http://127.0.0.1:7860


πŸ“‚ Project Structure

medical-simulator-demo/
β”‚
β”œβ”€β”€ backend/         # FastAPI backend (API + image processing)
β”‚   β”œβ”€β”€ app.py
β”‚   β”œβ”€β”€ processing.py
β”‚
β”œβ”€β”€ frontend/        # Simple static frontend
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ style.css
β”‚   └── app.js
β”‚
β”œβ”€β”€ main.py          # Entrypoint for FastAPI (uvicorn)
β”œβ”€β”€ requirements.txt # Python dependencies
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
└── .gitignore

πŸ“‚Testing with Python client (Optional)

For quick testing without the browser, a helper script client_process.py is included. It uploads an image to the backend and saves the processed result. To use this script, you should have the main.py running in the background. Place your input image in the root and:

# arterial phase example
python client_process.py --image CTA_Slice.jpg --phase arterial --out arterial.png

# venous phase example
python client_process.py --image CTA_Slice.jpg --phase venous --out venous.png

✨ How to Use

  1. 1.Open the web UI in your browser. Open http://127.0.0.1:7860
  2. 2.Drag & drop or select an image (.jpg/.png).
  3. 3.Choose phase: Arteriosa or Venosa.
  4. 4.Click Elabora immagine.
  5. 5.⏳ Status shows Processing… βœ… On success: Elaborazione completata.
  6. 6.Download your processed result.
  7. 7.You can always find the log file in your root folder "backend.log".