This guide will help you deploy the PulseGuard ECG analysis system, which analyzes ECG images to detect myocardial infarction (MI).
- Python 3.8 or higher
- 4GB RAM minimum (8GB recommended)
- GPU support optional but recommended for faster inference
Set up your project with the following structure:
pulse-guard/
├── additional_func.py # Core functions (from your original code)
├── streamlit_app.py # Streamlit application
├── requirements.txt # Package dependencies
├── models/
│ ├── yolo_ecg_model.pt # Your trained YOLO model
│ └── cnn_lstm_model.pt # Your trained CNN-LSTM model
└── README.md # Project documentation
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Place your model files:
Place your trained YOLO and CNN-LSTM model files in the
models/directory:- YOLO model at
models/yolo_ecg_model.pt - CNN-LSTM model at
models/cnn_lstm_model.pt
- YOLO model at
-
Update model paths (if needed):
If your model files are in different locations, update the
YOLO_MODEL_PATHandML_MODEL_PATHvariables instreamlit_app.py.
Start the Streamlit application:
streamlit run streamlit_app.pyThe application will be available at http://localhost:8501 by default.
- Create a GitHub repository with your project files
- Sign up for Streamlit Community Cloud
- Deploy directly from your GitHub repository
- Create a Dockerfile:
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 8501
CMD ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]- Build and run the Docker container:
docker build -t pulse-guard .
docker run -p 8501:8501 pulse-guardYou can deploy to platforms like Heroku, Google Cloud Run, or AWS Elastic Beanstalk following their respective deployment guides.
-
Model Size: The YOLOv8 and CNN-LSTM models can be large. Consider model optimization techniques like quantization for production.
-
Memory Management: Implement proper cleanup of temporary files and resources.
-
Authentication: Add user authentication for production deployment if dealing with sensitive data.
-
Monitoring: Implement logging and monitoring to track usage and detect errors.
To customize the application:
-
Logo: Add your own logo by uncommenting the logo section in
streamlit_app.pyand providing a logo file. -
UI Colors: Customize the Streamlit theme by creating a
.streamlit/config.tomlfile. -
Additional Features: Extend the application with features like report generation, patient database integration, or multi-model ensemble predictions.
For any issues or questions regarding deployment, please refer to the following resources: