Skip to content

peregrine-884/EcoFilter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

We have developed an intelligent trash bin equipped with AI technology. This trash bin automatically identifies whether a plastic bottle is recyclable or not, and removes non-recyclable items. As depicted in the gif below, it accurately detects labeled or capped plastic bottles.
動作デモGIF

This machine utilizes deep learning from YOLOv5 to detect plastic bottles, labels, and caps. In this project, we created an original dataset consisting of various plastic bottles with labels or caps, as well as those without such decorations. Additionally, we programmed the Jetson Nano to control a servo motor, allowing the machine to remove bottles with decorations.

Table of contents

  1. Background
  2. Requirements
  3. Set up
  4. Running the application
  5. How it works
  6. How the Intelligent Trash Bin Ejects plastic Bottles
  7. Data collection
  8. Training YOLOv5
  9. Future direction

Background

In waste management facilities, collected plastic bottles undergo a sorting process where labels, caps, and contaminated bottles are separated to recycle clean plastic bottles. This sorting is often performed manually, which is labor-intensive. By utilizing this smart trash bin, the workload at these facilities can be significantly reduced.

At the waste processing facility, plastic bottles are being sorted by hand
References : ペットボトルの分別について | 北見市

Requirements

Set up

Software

Next, you must set up PWM control pin in Jetson nano to operate a servo motor.
References:
SPI on Jetson – Using Jetson-IO
JetPack 4.3 (r32.3.1) で追加された Jetson-IO tool を使用して Pinmux テーブルを設定してみた。

  • Refer to the following website and follow the steps shown below
    • Input $ sudo /opt/nvidia/jetson-io/jetson-io.py on the terminal.
    • Select Configure 40-pin expansion header.
    • Select pwm0, pwm2.
    • Last, select Save and reboot reconfigure pins.

You can check that setting up successes with the command $ ls -l /boot/*.dtb and weather new .dtb file is created or not.

※If you can’t open jetson-io.py, you should try some fix ways. Especially, we fixed this trouble with the below commands.

Reference:Jetson Nano の GPIO にサーボモータをつないで制御してみる

cd /boot
sudo mkdir dtb
sudo cp *.dtb* dtb/

Then you can try again first command.

$ git clone https://github.com/hayato-hayashi/EcoFilter.git
$ pip install -r requirements.txt

※Important Instructions for Installing Dependencies:

When setting up your environment using pip install -r requirements.txt, it is crucial to ensure that the installation process does not overwrite the versions of any pre-installed software that came with the operating system. To prevent this, you should appropriately comment out any conflicting package versions listed in the requirements.txt file before running the installation command. This step helps maintain system stability and compatibility with pre-installed packages.

After successfully setting up the software and upon initial execution of our application, you may encounter a need for additional packages that were not previously identified. If such a situation arises, install these additional packages as required.

Hardware

Cardboard Selection

Our project involves covering the trash bin lid with a cardboard box. This cardboard box has the following features:

  1. Prevention of External Conditions:
    • It prevents external conditions such as weather and time of day from affecting the accuracy of the plastic bottle image recognition.
  2. Size Adjustment:
    • The cardboard box completely covers the lid. The length ensures space for placing the Jetson Nano, while the height is necessary to keep the discarded plastic bottles within the camera's field of view.

Modifications to the Trash Bin Lid

We have made the following improvements to the trash bin lid:

  1. Board Installation:
    • Two boards are installed on the lid to accommodate the Jetson Nano and motor.
    • The board is secured to the lid using screws and further stabilized with a Steel Restraint Strap to the sides of the lid.

※Both Arrow:Position of Board, Arrow:Position of (1)Motor, (2)Web Camera and (3)Compact light
  1. Lid Improvement:
    • Screws securing the board and lid penetrate part of the base of the trash bin, making the lid inseparable in its original design.
    • For the attachment point with the board in front of the trash can, a vertical groove was made in the bottom of the trash can to allow the lid and bottom to be separated so that the contents can be removed smoothly.

Camera Installation

  1. Cylinder Creation:

    • Create a cylinder from a plastic sheet large enough to fit a plastic bottle.
  2. Making a Hole:

    • Cut a square hole in the front of the cardboard and install the cylinder.
    • The cylinder is mounted at an angle of approximately 25° downward toward the trash can.
  3. Camera Positioning:

    • To stabilize the camera, use a wooden board to secure it as shown in the photo above. Also, adjust the position of the camera so that the entire cylinder fits within its field of view.
    • Install a baffle outside the intake to prevent light from entering.

Installation of Various Components

  1. Installation of Motor and Light:
    • Secure the motor and light to the cardboard and connect them to the Jetson Nano like the picture at the section Borard Installation.
    • Adjust the motor's angle of movement, the length of the rod, and the dimensions of the cylinder to ensure proper holding, ejection, and acceptance of the plastic bottles.
  2. Power Cord Installation:
    • Once the Jetson Nano is installed, drill a hole at the bottom of the trash bin to pass through the power cord.

Running application

After setting up about software and hardware preparation, Input below command and wait a several minutes.

$ python3 eco_filter.py

After this, some logs output at terminal. When ready to operate, "now active and running" will be displayed in the terminal. Then you can use our intelligent trash box. Try to insert some plastic bottles. Please note that you shouldn’t insert a new bottle while this trash box is processing a bottle you entered. If all goes well, the plastic bottle should be put into the box or taken out of the box.

How it Works

This application leverages YOLOv5 on the Jetson Nano 2GB, optimizing for rapid object detection within the constraints of limited memory. The primary focus is on processing video feed from a camera to detect three key objects: plastic bottles, their labels, and caps. Based on the detection of these items, the system determines whether a plastic bottle is recyclable. If deemed recyclable, the bottle is accepted by the trash bin; otherwise, a motor mechanism ejects it from the bin.

The following figure illustrates a scheme for the method:

Detailed Process:

  1. Initialization: The Jetson Nano and application are started, ready to process incoming video feed.
  2. Bottle Detection: As a plastic bottle is introduced into the trash bin's entry point, the application, powered by YOLOv5 on the Jetson Nano, detects the bottle along with its label and cap.
  3. Recyclability Assessment: The application evaluates whether the bottle can be recycled based on the presence of a label and cap.
    • If the bottle lacks a label and cap, it is deemed recyclable and accepted by the trash bin.
    • If a label or cap is detected, the system rejects the bottle, activating a motor to eject it from the bin.
  4. Motor Mechanism: A servo motor manipulates a panel to manage the bottle's fate:
    • The panel swings back to accept recyclable bottles.
    • It pushes forward to eject non-recyclable bottles outside the bin.

This smart recycling system not only simplifies waste management but also promotes environmental sustainability by ensuring proper segregation of recyclable materials.

How the Intelligent Trash Bin Ejects Plastic Bottles

One of the key challenges in designing an automated system for waste management is ensuring that non-recyclable items can be efficiently separated and ejected from the bin. In our Intelligent Trash Bin project, we've implemented a couple of ingenious solutions to address this challenge effectively.

Ejection Mechanism

Our design incorporates a specialized ejection mechanism that leverages a combination of mechanical ingenuity and precise control. Here are the main innovations we've made:

  • Adjustable Plastic Cylinder: The bin's intake is equipped with a plastic cylinder that acts as a conduit for plastic bottles. We meticulously adjusted the lengths of the upper and lower surfaces of this cylinder to optimize the ejection process. This adjustment ensures that a wooden rod, swung by a servo motor, can effectively push up and eject the plastic bottle from the cylinder.

  • Strategic Intake Placement: The intake is created by cutting a portion of the cardboard that encases the trash bin and inserting the adjusted plastic cylinder. A crucial innovation here is the placement of the intake with tape on the upper side rather than the lower side of the cut-out in the cardboard. This placement makes it easier for the intake to lift during the ejection process, facilitating smoother discharge of the plastic bottles.

Discharging plastic bottle Placing plastic bottle inside

These design choices are central to the Intelligent Trash Bin's ability to differentiate and eject non-recyclable plastic bottles. By fine-tuning the physical components and their interactions, we've achieved a system that not only automates waste segregation but does so with high efficiency and reliability.

Data Collection

To accurately recognize plastic bottles, caps, and labels, we undertook a comprehensive data collection process. Our goal was to gather images that reflect the variety of ways a plastic bottle can appear when introduced into the trash bin. We created a holding area at the trash bin's entrance, made from transparent plastic sheets, to ensure bottles remained in place during image capture. The camera was positioned to capture the entire holding area within its field of view.

Collection Procedure:

  1. Preparing the Bottles: We started with a collection of approximately 150 plastic bottles in various conditions. Instead of preparing separate groups of bottles with and without labels and caps, we utilized the same set of bottles for multiple stages of data collection. Initially, we photographed each bottle in its current state, capturing images of bottles with labels and caps intact. Subsequently, we removed the caps from these bottles and took additional photographs. Finally, we removed both the labels and caps, capturing images of the bottles in a completely unadorned state. This method allowed us to create a diverse dataset from a fixed number of bottles, ensuring a wide range of conditions were represented in our training data.

  2. Capturing Images: The photographic process was carefully designed to avoid detection inaccuracies due to the orientation of bottle insertion. For each stage of bottle preparation (with labels and caps, with caps removed, and with both removed), we captured images in two orientations: cap-first and cap-last. This approach ensured our model would learn to recognize bottles irrespective of how they were introduced into the bin. Each bottle's various states were documented from multiple angles to further enhance the model's accuracy and robustness in real-world scenarios.

  3. Annotation Process: Each image was annotated to identify the entire bottle, label, and cap positions using the VoTT. The annotations were initially saved in the Pascal VOC format (XML output), which were later converted to the YOLOv5 format through web tools (Convert Pascal VOC Format to YOLO Format) for compatibility.

  4. Image Augmentation: To enhance our dataset, we manipulated the brightness of images for augmentation, effectively increasing our dataset without needing to physically collect more samples. This process resulted in approximately 1000 annotated images ready for training.

Training YOLOv5

Training was performed on this dataset using YOLOv5. Below is a summary of the steps we followed:

Training in Google Colaboratory:

  1. Augment the training data.
  • Adjust the paths to the image and label folders, as well as the number of images to augment, in the data augmentation program file.
    Below is a image of the code from the file label_Inflated_water.py, which users should adjust as needed :
  • Next, execute the following command to augment the data.
$ python3 label_Inflated_water.py
  1. Run the YOLOv5 training program to obtain the best.pt file.
  • Create pet.yaml. This file specifies the folder path, number and name of detection targets, and must be placed in the same folder as train.py. The following is an example of pet.yaml.
# Dataset name
path: data  # Path to the dataset
train: train  # Directory where training images and labels are located
val: valid  # Directory where validation images and labels are located

# Class information
nc: 3  # Number of classes
names: ['cap', 'label', 'pet']  # Class names
  • Execute the following command to train the model using the data you created.
$ python train.py --batch 16 --epochs 30 --data pet.yaml --weights yolov5s.pt 
  • The best.pt file can be obtained from train/runs/exp/weights. It can be used by placing it in the same folder as the eco_filter.py.

Future directions

The current model has been trained using approximately a hundred plastic bottles collected from various locations within Gifu University's campus, resulting in a prediction capability limited to the preferences of Gifu University students. In the future, I plan to enhance the prediction capability by incorporating data on plastic bottle preferences from individuals across different age groups, including the elderly and children.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages