File size: 1,428 Bytes
a4f90fa 6f5feff | 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 | # HEMAS NeuroTrack FastAPI
This project ports the complete notebook logic from `gait2 (5).ipynb` into a FastAPI app with Swagger UI.
## Run
```bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app:app --reload
```
Open Swagger UI:
- http://127.0.0.1:8000/docs
## Endpoint
- `POST /analyze`
- form-data:
- `video`: video file (front-view gait)
- `patient_gender`: `male` or `female`
Response includes:
- clinical interpretation text (same wording/thresholds as notebook)
- gait score and interpretation
- full feature values
- URL to annotated output video
- URL to biomarker plot image
## Automatic cleanup for runs/
Generated files from `/analyze_files` are stored under `runs/outputs`.
To prevent storage growth, use the cleanup script every 30 minutes.
Script path:
- `scripts/cleanup_runs.py`
Behavior:
- Deletes files older than 30 minutes (default)
- Removes empty subdirectories
### Local host cron example
```bash
*/30 * * * * /usr/bin/python3 /path/to/GAIT_API/scripts/cleanup_runs.py --path /path/to/GAIT_API/runs --max-age-minutes 30 >> /var/log/gait_cleanup.log 2>&1
```
### Docker container cron example (host cron running docker exec)
```bash
*/30 * * * * docker exec gait-api python /app/scripts/cleanup_runs.py --path /app/runs --max-age-minutes 30 >> /var/log/gait_cleanup.log 2>&1
```
Replace `gait-api` with your running container name.
|