Sandahk/medical-simulator-demo
0
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)
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).
# 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
- Open the web UI in your browser. Open http://127.0.0.1:7860
- Drag & drop or select an image (
.jpg/.png). - Choose phase: Arteriosa or Venosa.
- Click Elabora immagine.
- β³ Status shows Processingβ¦ β On success: Elaborazione completata.
- Download your processed result.
- You can always find the log file in your root folder "backend.log".
