Skip to content

Commit

Permalink
Completed the code
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharias1219 committed Dec 3, 2024
1 parent 0894aee commit 34d900c
Show file tree
Hide file tree
Showing 4 changed files with 268 additions and 1 deletion.
Empty file removed .github/workflows/.gitkeep
Empty file.
98 changes: 98 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: workflow

on:
push:
branches:
- main
paths-ignore:
- 'README.md'

permissions:
id-token: write
contents: read

jobs:
integration:
name: Continuous Integration
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Lint code
run: echo "Linting repository"

- name: Run unit tests
run: echo "Running unit tests"

build-and-push-ecr-image:
name: Continuous Delivery
needs: integration
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Install Utilities
run: |
sudo apt-get update
sudo apt-get install -y jq unzip
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_NAME }}
IMAGE_TAG: latest
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
Continuous-Deployment:
needs: build-and-push-ecr-image
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1


- name: Pull latest images
run: |
docker pull ${{secrets.AWS_ECR_LOGIN_URI}}/${{ secrets.ECR_REPOSITORY_NAME }}:latest
# - name: Stop and remove container if running
# run: |
# docker ps -q --filter "name=cnncls" | grep -q . && docker stop cnncls && docker rm -fv cnncls

- name: Run Docker Image to serve users
run: |
docker run -d -p 8080:8080 --name=cnncls -e 'AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}' -e 'AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}' -e 'AWS_REGION=${{ secrets.AWS_REGION }}' ${{secrets.AWS_ECR_LOGIN_URI}}/${{ secrets.ECR_REPOSITORY_NAME }}:latest
- name: Clean previous images and containers
run: |
docker system prune -f
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.8-slim-buster

RUN apt update -y && apt install awscli -y
WORKDIR /app

COPY . /app
RUN pip install -r requirements.txt

CMD ["python3", "app.py"]
162 changes: 161 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,161 @@
# chest-cancer-classification
# **Chest Cancer Classification Project with MLOps**

This project showcases an **end-to-end deep learning implementation** for classifying chest cancer using CT scan images. Leveraging **MLflow** and **DVC**, this project incorporates MLOps principles, focusing on efficient experiment tracking, modular pipeline design, and deployment-ready solutions.

---

## **Features**

- **Comprehensive Workflow**:
- Modular implementation of deep learning pipelines.
- Utilizes MLflow for experiment tracking and model registration.
- Tracks and optimizes data pipelines with DVC.

- **Scalable Framework**:
- Seamless integration of MLflow with local and remote servers.
- CICD-based deployments using Docker and cloud platforms.

- **User-Friendly Interface**:
- Deployable web app for cancer classification.
- Real-time predictions from CT scan images.

---

## **Tech Stack**

- **Languages**: Python
- **Libraries**: TensorFlow, Keras, MLflow, DVC
- **Deployment**: Docker, AWS, Azure
- **Frontend**: HTML, CSS (basic)
- **Version Control**: GitHub

---

## **Directory Structure**

├── app
│ ├── api
│ ├── pipeline
│ ├── templates
│ ├── utils
├── data
│ ├── raw
│ └── processed
├── experiments
│ └── MLflow runs and metadata
├── docker
├── models
├── notebooks
│ └── experiment_notebooks
└── requirements.txt

---

## **Getting Started**

### **Prerequisites**

1. **Python**: Install Python 3.8 or later.
2. **MLflow**: Set up MLflow locally or on a remote server like DagsHub or AWS.
3. **DVC**: Install DVC for data versioning.
4. **Docker**: Required for deployment.
5. **Cloud Accounts**: AWS and Azure credentials for deployment.

### **Installation**

1. Clone the repository:

```bash
git clone https://github.com/yourusername/chest-cancer-classification.git
cd chest-cancer-classification
```

2. Install dependencies:

```bash
pip install -r requirements.txt
```

3. Set up MLflow tracking URI:
- For local: `http://localhost:5000`
- For remote: Configure with your cloud-based URI.

---

## **How It Works**

### **Pipeline Overview**

1. **Data Ingestion**:
- Raw CT scan images are processed into labeled datasets.
- Metadata is managed using DVC.

2. **Preprocessing**:
- Data augmentation techniques applied to normalize and enhance images.

3. **Training and Experimentation**:
- Model training using TensorFlow with hyperparameter tuning.
- MLflow tracks all experiment parameters, metrics, and artifacts.

4. **Deployment**:
- Web application built to accept images and provide predictions.
- Dockerized app deployed on AWS or Azure using CICD pipelines.

---

## **Project Highlights**

- **MLflow Experiment Tracking**:
- Automatic logging of parameters, metrics, and models.
- Supports both local and cloud deployments.

- **DVC Integration**:
- Tracks dataset versions and ensures data consistency.

- **Web Interface**:
- Intuitive image uploader to classify chest cancer from CT scans.
- Predicts cancer types such as Adenocarcinoma.

---

## **Example Usage**

- **Run MLflow Server**:

```bash
mlflow ui
```

- **Execute Training Pipeline**:

```bash
python app/api/train.py --config config/train_config.yaml
```

- **Launch Application**:

```bash
docker-compose up
```

---

## **Future Enhancements**

- Expand dataset for better accuracy.
- Improve web app UI using modern frameworks.
- Automate pipeline with more MLOps tools.

---

## **Contributing**

We welcome contributions! Please fork the repository and submit a pull request.

---

## **License**

MIT License - See [LICENSE](./LICENSE) for details.

---

0 comments on commit 34d900c

Please sign in to comment.