Coder Social home page Coder Social logo

daniabib / overweight-dogs Goto Github PK

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

:dog: PyTorch image classifier to classify images of overweight dogs. The model is a pretrained EfficientNet-B0 with a custom classify layer on top.

Python 93.01% Dockerfile 6.99%
pytorch computer-vision fastapi docker

overweight-dogs's Introduction

Overweight Dogs Image Classifier

Ovwscreen

A simple example of a PyTorch image classifier to classify images of overweight dogs. The model is a pretrained EfficientNet-B0 with a custom classify layer on top.

The dataset was built scraping Bing Image for terms like "overweight dogs", "obese dogs" and similars. I also wrote some scripts to extract frames of videos containing overweighted dogs to achieve a more robust dataset. The dataset is composed of 5400 images already randomly split into train, validation, and test folders. It can be downloaded here: https://drive.google.com/file/d/1uFDfpyCkMxzdz2Mez5zUBJJHBkh_OJjq/view?usp=sharing

Just for the sake of completeness (and fun!) I added an API call to the AWS Rekognition Label Detection service, so our model is called only when a dog is in the picture. That way our application can function as an object detector too.

A simple Streamlit frontend was built to simplify the use of the model by clients. The model is integrated with FastAPI, and can be accessed on the /prediction endpoint. It is already deployable via Docker and has GPU support if needed.

The application is also already deployable on AWS ECS.

How To Use

To clone and run this application, you'll need Git and Docker:

# Clone this repository
$ git clone https://github.com/daniabib/overweight-dogs

# Go into the repository
$ cd overweight-dogs

Then you need to build and run the Docker image:

# Build and run the image
$ docker-compose up -d --build

The Streamlit frontend will be avaiable at http://localhost:8501.

To test the model you can use the FastAPI documentation page. It will be avaiable on http://0.0.0.0:8080/docs.

You can also use a HTTP client like httpie, for example:

$ http --form http://0.0.0.0:8080/prediction [email protected]

It will return something like this:

HTTP/1.1 200 OK
content-length: 25
content-type: application/json
date: Fri, 18 Mar 2022 21:09:45 GMT
server: uvicorn

{
    "category": "overweight"
}

Things I'm still implementing

  • A simple Streamlit frontend.
  • A docker-compose pipeline to simplify deployment on AWS ECS.

References

For this code, I used a variety of sources, but mainly these:

Disclaimer

This repository is just an exercise on deep learning, computer vision, and model deployment. It has no intention of having any scientific validation. Please, use it only as a code example.

overweight-dogs's People

Contributors

daniabib avatar

Watchers

 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.