Coder Social home page Coder Social logo

eziodevio / dog-breed-classifier-mlops Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 2.57 MB

comprehensive guide to setting up a complete MLOps pipeline for a Dog Breed Classifier application using Teachable Machine, TensorFlow, Flask, Docker, and CI/CD practices

License: MIT License

Python 53.35% CSS 11.92% JavaScript 8.90% HTML 14.32% Dockerfile 11.50%
docker flask-application machine-learning mlops tensorflow

dog-breed-classifier-mlops's Introduction

Build and Push to GHCR

Dog Breed Classifier - MLOps Tutorial

This repository provides a comprehensive guide to setting up a complete MLOps pipeline for a Dog Breed Classifier application using Teachable Machine, TensorFlow, Flask, Docker, and CI/CD practices. The goal is to demonstrate how Machine Learning (ML) models are integrated within a continuous integration and continuous deployment (CI/CD) framework.

Overview

This tutorial will cover:

  • Training a model with Google's Teachable Machine
  • Setting up a Flask application to serve predictions
  • Containerizing the application with Docker
  • Implementing a CI/CD pipeline using GitHub Actions

Prerequisites

  • Git
  • Python 3.8+
  • Docker
  • A GitHub account
  • Basic familiarity with Flask and Docker

Step 1: Training the Model

  1. Visit Teachable Machine, create a new image project, upload images of various dog breeds, train the model, and export it as a TensorFlow model.
  2. Download the model.json and weights.bin files.

Step 2: Flask Application Setup

Create a basic Flask application to serve the model. The application will allow users to upload an image and receive the dog breed prediction.

Project Structure

Dog-Breed-classifier-MLOps/ │ ├── app/ │ ├── static/ │ │ ├── css/ │ │ ├── js/ │ │ └── images/ │ ├── templates/ │ ├── init.py │ ├── views.py │ └── predict.py │ ├── model/ │ ├── model.json │ ├── group1-shard1of1.bin │ ├── tests/ │ ├── test_app.py │ ├── Dockerfile ├── requirements.txt └── README.md

Implementation

  • Flask serves a webpage that allows users to upload images.
  • Predictions are made using the TensorFlow model loaded in Flask.

Step 3: Dockerization

Containerize the Flask application using Docker to ensure it can be deployed consistently across any environment.

# Use a lightweight Python base image
FROM python:3.9-slim

WORKDIR /app
COPY . /app

RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 5000

CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:create_app()"]

Step 4: CI/CD Pipeline with GitHub Actions

Set up GitHub Actions to automate testing, building, and deploying the Flask application.

Workflow

  1. Continuous Integration:

    • Run tests.
    • Build the Docker image.
  2. Continuous Deployment:

    • Push the Docker image to a registry.
    • Deploy the image to a hosting service like Heroku or AWS.
name: CI/CD Pipeline

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.9

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt

      - name: Run tests
        run: |
          pytest

      - name: Build and push Docker image
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          tags: user/myapp:latest

Conclusion

This tutorial provides a basic framework for building a MLOps pipeline that incorporates machine learning model training, a web application, Docker containerization, and a CI/CD workflow. It aims to guide the integration of machine learning development with production operations to improve the automation and monitoring at all steps of ML system construction.

dog-breed-classifier-mlops's People

Contributors

theslash84 avatar

Watchers

Kostas Georgiou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.