CoolFace
Apppublic

ALYYAN/chest-cancer-classifier-app

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

<div align="center">

๐Ÿฉบ End-to-End Chest Cancer Classification

An MLOps project demonstrating the complete lifecycle of a deep learning model, from data ingestion to CI/CD-powered deployment.

![CI/CD Pipeline](https://github.com/AlyyanAhmed21/End-to-End-Chest-Cancer-Classification-using-MLflow-and-DVC/actions/workflows/main.yaml) ![License: MIT](https://opensource.org/licenses/MIT) ![Python Version](https://www.python.org/downloads/release/python-380/)

</div>


๐Ÿš€ Live Demo

Experience the deployed application live on Hugging Face Spaces!

[โžก๏ธ Live Demo Link](https://huggingface.co/spaces/alyyan/chest-cancer-classifier-app)

(Note: The Space may be asleep if it hasn't been used recently. Please allow a moment for it to wake up.)

๐Ÿ–ผ๏ธ Application Screenshot

Here is the user interface of the deployed web application.

[image])

๐Ÿ“– About The Project

This project implements a complete end-to-end MLOps pipeline for a Chest Cancer image classification task. A deep learning model (based on VGG16/ResNet) is trained to distinguish between Normal and Adenocarcinoma chest CT scans.

The primary focus is not just on the model's accuracy, but on building a robust, reproducible, and automated system using modern MLOps tools.

Key Features:

  • โ€”Experiment Tracking: Uses MLflow to log parameters, metrics, and model artifacts for every run.
  • โ€”Data & Model Versioning: Uses DVC to version large data files and models, keeping the Git repository lightweight.
  • โ€”Automated CI/CD: A GitHub Actions workflow automatically tests, builds, and deploys the application on every push to the main branch.
  • โ€”Web Application: A user-friendly Flask application serves the trained model for real-time predictions.
  • โ€”Containerization: The entire application is containerized with Docker for consistent and portable deployment.
  • โ€”Cloud Deployment: Deployed for free on Hugging Face Spaces.

๐Ÿ› ๏ธ Tech Stack

  • โ€”Backend: Python, Flask
  • โ€”Model: TensorFlow, Keras
  • โ€”MLOps Tools: MLflow, DVC, Dagshub (for remote tracking)
  • โ€”CI/CD & Deployment: Docker, GitHub Actions, Hugging Face Spaces

๐ŸŒŠ MLOps Workflow

The project follows a structured MLOps workflow, which is fully automated by the CI/CD pipeline.

<pre><code class="language-mermaid"> graph TD A[Start: Push Code to GitHub] --> B{GitHub Actions CI/CD}; B --> C[CI: Install Dependencies & Run Tests]; C -->|Success| D[CD: Deploy to Hugging Face]; D --> E[๐Ÿš€ Live Application];

subgraph "DVC & MLflow Cycle (Local/Remote)" F[1. dvc repro] --> G[2. Pull Data (DVC)]; G --> H[3. Train Model]; H --> I[4. Log Metrics & Model (MLflow)]; I --> J[5. Push Model (DVC)]; end </code></pre>

โš™๏ธ Getting Started - Local Setup

To run this project on your local machine, follow these steps.

Prerequisites

  • โ€”Git
  • โ€”Python 3.8+
  • โ€”A DagsHub account (for MLflow tracking)

Installation & Setup

  1. 1.Clone the repository:
bash
    git clone https://github.com/AlyyanAhmed21/End-to-End-Chest-Cancer-Classification-using-MLflow-and-DVC.git
    cd End-to-End-Chest-Cancer-Classification-using-MLflow-and-DVC
  1. 1.Create a virtual environment:
bash
    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. 1.Install dependencies:
bash
    pip install -r requirements.txt
  1. 1.Set up MLflow/DagsHub credentials: Create a .env file in the root directory and add your credentials. This file is ignored by Git.
env
    MLFLOW_TRACKING_URI="https://dagshub.com/YourUsername/YourRepoName.mlflow"
    MLFLOW_TRACKING_USERNAME="YourUsername"
    MLFLOW_TRACKING_PASSWORD="YourDagsHubAccessToken"
  1. 1.Run the DVC pipeline: This command will execute all stages defined in dvc.yaml (data ingestion, model preparation, training, and evaluation).
bash
    dvc repro
  1. 1.Run the Flask application:
bash
    python app.py

Open your browser and navigate to http://localhost:8080 to use the app.

๐Ÿ“ Project Structure

.
โ”œโ”€โ”€ .dvc/                # DVC metadata
โ”œโ”€โ”€ .github/workflows/   # GitHub Actions CI/CD pipeline
โ”œโ”€โ”€ artifacts/           # (Generated by DVC) Data, models, etc.
โ”œโ”€โ”€ config/              # Configuration files (config.yaml)
โ”œโ”€โ”€ src/                 # Source code for the project
โ”‚   โ””โ”€โ”€ cnnClassifier/
โ”‚       โ”œโ”€โ”€ components/    # Individual pipeline components
โ”‚       โ”œโ”€โ”€ config/        # Configuration management code
โ”‚       โ”œโ”€โ”€ entity/        # Custom entity definitions
โ”‚       โ”œโ”€โ”€ pipeline/      # DVC pipeline stage definitions
โ”‚       โ””โ”€โ”€ utils/         # Utility functions
โ”œโ”€โ”€ templates/           # HTML templates for the Flask app
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ app.py               # Main Flask application entrypoint
โ”œโ”€โ”€ dvc.yaml             # DVC pipeline definition
โ”œโ”€โ”€ Dockerfile           # Docker configuration for deployment
โ”œโ”€โ”€ main.py              # Main project orchestrator
โ”œโ”€โ”€ params.yaml          # Model parameters
โ””โ”€โ”€ requirements.txt     # Python dependencies

๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.


<div align="center">

Star the repo if you found it useful! โญ

</div>