medical-report-analyzer / DEPLOYMENT.md
snikhilesh's picture
Upload folder using huggingface_hub
023df37 verified
|
raw
history blame
4.4 kB

Deployment Guide for Hugging Face Spaces

Prerequisites

  • Hugging Face account
  • HF_TOKEN (optional, for model access if needed)
  • GPU Space (T4 or A100 recommended)

Deployment Steps

1. Create a New Space

  1. Go to https://huggingface.co/new-space
  2. Choose a name: medical-report-analysis-platform
  3. Select SDK: Docker
  4. Select Hardware: GPU T4 (or higher)
  5. Set visibility: Public or Private

2. Configure Space

Create the following files in your Space:

Dockerfile

FROM python:3.10-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    tesseract-ocr \
    poppler-utils \
    libgl1-mesa-glx \
    libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements and install
COPY backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY backend/ ./backend/
COPY medical-ai-frontend/dist/ ./backend/static/

# Expose port
EXPOSE 7860

# Environment variables
ENV PYTHONUNBUFFERED=1
ENV PORT=7860

# Run application
CMD ["python", "backend/main.py"]

README.md

---
title: Medical Report Analysis Platform
emoji: πŸ₯
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
license: mit
---

# Medical Report Analysis Platform

Advanced AI-powered medical document analysis using 50+ specialized models.

## Features

- Multi-modal PDF processing
- 50+ specialized medical AI models
- Real-time analysis visualization
- HIPAA/GDPR compliant architecture

## Usage

1. Upload a medical PDF report
2. Wait for AI analysis (30-60 seconds)
3. Review comprehensive results

**Disclaimer**: This platform provides AI-assisted analysis. All results must be reviewed by qualified healthcare professionals.

3. Upload Files

Upload the following directory structure:

your-space/
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ README.md
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ main.py
β”‚   β”œβ”€β”€ pdf_processor.py
β”‚   β”œβ”€β”€ document_classifier.py
β”‚   β”œβ”€β”€ model_router.py
β”‚   β”œβ”€β”€ analysis_synthesizer.py
β”‚   └── requirements.txt
└── medical-ai-frontend/
    └── dist/
        β”œβ”€β”€ index.html
        └── assets/

4. Environment Variables (Optional)

If you need to access gated models:

  1. Go to Space Settings β†’ Variables
  2. Add:
    • Key: HF_TOKEN
    • Value: Your Hugging Face token

5. Build and Deploy

The Space will automatically:

  1. Build the Docker container
  2. Install all dependencies
  3. Start the application on port 7860
  4. Serve both backend API and frontend UI

6. Access Your Application

Once deployed, your Space will be available at:

https://huggingface.co/spaces/YOUR_USERNAME/medical-report-analysis-platform

Monitoring

Check Logs

View logs in the Space's "Logs" tab to monitor:

  • Application startup
  • Request processing
  • Error messages

Performance

  • Initial load: 2-5 minutes (building Docker image)
  • Analysis time: 30-60 seconds per document
  • Concurrent users: Depends on GPU hardware

Troubleshooting

Common Issues

  1. Out of Memory

    • Upgrade to A100 GPU
    • Reduce concurrent processing
    • Implement request queuing
  2. Slow Performance

    • Check GPU utilization
    • Optimize model loading
    • Enable model caching
  3. Build Failures

    • Verify all files are uploaded
    • Check requirements.txt syntax
    • Review Dockerfile syntax

Debug Mode

To enable debug logging, add to Dockerfile:

ENV LOG_LEVEL=DEBUG

Scaling Considerations

For production deployment:

  1. Load Balancing: Use HF Spaces Replicas
  2. Caching: Implement Redis for job tracking
  3. Storage: Use external storage for large files
  4. Monitoring: Set up health checks and alerts

Security Notes

  • Files are processed in temporary storage
  • No persistent file storage by default
  • Implement user authentication for production
  • Add rate limiting for API endpoints

Cost Estimation

Hugging Face Spaces pricing (approximate):

  • T4 GPU: ~$0.60/hour
  • A10G GPU: ~$1.10/hour
  • A100 GPU: ~$4.13/hour

For 24/7 operation with T4:

  • Monthly cost: ~$432

Support

For issues or questions:

  • Check Space logs
  • Review README documentation
  • Contact space maintainer

Medical Report Analysis Platform - Advanced AI-Powered Clinical Intelligence