Coder Social home page Coder Social logo

cybermated / smartbin_ai Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 1.0 110 KB

Smartbin AI is a personal project aiming at training an artifial intelligence to recognise waste material using Tensorflow.

Python 100.00%
python tensorflow image-detection video-detection

smartbin_ai's Introduction

Smartbin

Codacy Badge

Smartbin AI is a personal project aiming at training an artifial intelligence from scratch to detect garbage (plastic bottles, cans, tin cans, plastic containers...). It relies on both Tensorflow and OpenCV for Python 3.

The following document covers every step from gathering images to training the AI and testing it.

Installation

The instructions below have been tested on CentOS 7 and Ubuntu 18.04 (with and without graphical interface).

Start by cloning this repository.

sudo apt install -y git-core
git clone https://github.com/Cybermated/Smartbin_AI.git

Make sure Python 3 is installed on your machine as well as Pip for Python 3.

sudo apt install -y python3-minimal python3-setuptools python3-dev
python3 --version
Python 3.x.x

On headless servers make sure to install the following packages.

# For Debian-based installations.
sudo apt install -y libsm6 libxrender1 libfontconfig1
# For Redhat-based installations.
sudo yum install -y libXext libSM libXrender

Setup Pipenv and restore the environment from requirements.txt. Install errors may raise during the process.

sudo apt install -y python3-pip
pip3 install --user pipenv
cd Smartbin_AI
pipenv install -r requirements.txt --skip-lock --clear
pipenv shell

Install protobuf. It is required for the training.

sudo apt install -y autoconf automake libtool curl make g++ unzip
cd /tmp
# Make sure you grab the latest version.
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.7.1/protoc-3.7.1-linux-x86_64.zip
unzip protoc-3.7.1-linux-x86_64.zip -d protoc3
sudo mv protoc3/bin/* /usr/local/bin/
sudo mv protoc3/include/* /usr/local/include/

# Optional: change owner.
sudo chown $USER /usr/local/bin/protoc
sudo chown -R $USER /usr/local/include/google

# Refresh librairies.
sudo ldconfig

# Check version.
protoc --version
libprotoc 3.7.1

Install Tensorflow models.

mkdir tensorflow
git clone https://github.com/tensorflow/models.git
cd models/research
protoc object_detection/protos/*.proto --python_out=.

The following commands must be executed in the Pipenv you created earlier.

Install the pycocotools. It is in the requirements file but it may have failed.

sudo apt install -y gcc
cd /tmp
git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
make
cp -r pycocotools path/to/tensorflow/models/research/

Export to PYTHONPATH Tensorflow models:

cd path/to/tensorflow/models/research
python3 setup.py install
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
source ~/.bashrc

Usage

Collect images

The first step is to gather images of what you want to detect. In this "tutorial" we will take for examples dogs, cats and sheeps. Start by editing the config.py file and change the following line.

ROI_CLASSES = ['sheep', 'dog', 'cat']

Run generate_labelmap.py:

python3 generate_labelmap.py

A file named "labelmap.pbtxt" must have appeared in the training/config folder. It is possible to add new classes afterwards but the labelmap file must be regenerated as it maps each class name to an internal ID for Tensorflow. Also, make sure to not modify the order of the classes.

Then, you must gather images of sheeps, cats and dogs. Images must be big enough and you should have several kinds of sheeps, cats and dogs. We recommend at least 2000 images per class but you can start with 100 if you plan to use the augmentation script.

Put the images in the pretraining/raw_images folder.

You can also shoot videos by yourself, in this case put them in the pretraining/raw_videos folder. Then run the extract_frames.py.

python3 extract_frames.py

New images must have appeared in the raw_images folder.

Generate folders

To be added.

Export ROIs

To be added.

Train model

To be added.

Test model

To be added.

Contributing

To be added.

License

To be added.

smartbin_ai's People

Contributors

cybermated avatar

Forkers

codacy-badger

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.