{"id":26205040,"url":"https://github.com/pizaariaaa/garbage-classification","last_synced_at":"2025-04-15T07:38:20.552Z","repository":{"id":142179410,"uuid":"585240987","full_name":"PizaaRiaaa/garbage-classification","owner":"PizaaRiaaa","description":"Python notebook about garbage detection based on convolutional neural network","archived":false,"fork":false,"pushed_at":"2025-02-19T11:13:53.000Z","size":45305,"stargazers_count":20,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T17:57:28.347Z","etag":null,"topics":["convolutional-neural-networks","deep-learning","garbage-classification","jupyter-notebook","machine-learning","python"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PizaaRiaaa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-04T17:10:24.000Z","updated_at":"2025-03-28T07:11:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"16aea8a3-e9fe-42c5-ad3a-40e1b829788f","html_url":"https://github.com/PizaaRiaaa/garbage-classification","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PizaaRiaaa%2Fgarbage-classification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PizaaRiaaa%2Fgarbage-classification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PizaaRiaaa%2Fgarbage-classification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PizaaRiaaa%2Fgarbage-classification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PizaaRiaaa","download_url":"https://codeload.github.com/PizaaRiaaa/garbage-classification/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249029046,"owners_count":21200951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["convolutional-neural-networks","deep-learning","garbage-classification","jupyter-notebook","machine-learning","python"],"created_at":"2025-03-12T04:33:36.391Z","updated_at":"2025-04-15T07:38:20.520Z","avatar_url":"https://github.com/PizaaRiaaa.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Garbage Detection Based on Convolutional Neural Network\nFinal project for an application of machine learning and deep learning course (ITC C508). The code has been made available as a reference if anyone would like to reproduce the results of this project.\n\n```Please cite this  project if this repository is useful for your research.```\n\nRecycling trash is a crucial part of protecting our environment. Garbage must be divided into categories with similar recycling processes in order to enable the recycling process. The percentage of recycled waste can rise considerably if it is possible to separate domestic trash into several categories. Using the classes given, we trained the model in this notebook to categorize the input images and output the trash classification.\n\n## Project Overview\n![screenshot](preview/screenshot.png)\n* The objective of this study is to train the model to be able to predict the input images and classify it into one of the\ngarbage recycling categories, which includes cardboard, glass, metal, paper, plastic, trash.\n* The CNN generated an accuracy score of ```92.96%``` which proved that this model has a potential to be used  a a tool for \npredicting garbage clases.\n* Dataset includes cardboard(393), glass(491), metal(400), paper(584), plastic(472), trash(127)\n\n![class-distribution](preview/class-distribution.png)\n\n## Built with\n* Python\n* Jupyter Notebook\n\n## Getting started\nTo get the local copy of this repository, please run the following commands on your terminal:\n\n```git clone https://github.com/PizaaRiaaa/Synapse.git](https://github.com/PizaaRiaaa/garbage-classification.git```\n\n* Read fullpaper: [click here](fullpaper/Final-Paper_Semaphore.pdf)\n* locate original images: [click here](Garbage/original_images)\n* locate processed images: [click here](Garbage/processed_images)\n\n## Libraries\n* tensorflow\n* Sequential\n* keras.layers\n* ImageDataGenerator\n* sklearn.metrics\n* keras\n* PIL\n* pathlib\n* scipy\n* os\n* numpy\n* matplotlib.pyplot\n* torchvisio.datasets\n* torchvision.transform\n\n## Data Preprocessing\nSteps that were applied for the data preprocessing for all the images in the dataset. \nEach step is decribed below:\n* ```Step 1:``` Resized all the images in the dataset to 32x32 pixel to match the input layer of the model\n* ```Step 2:``` Converted all the images to grayscale to simplify the model's algorithm and computational requirements\n* ```Step 3:``` Normalized image dataset by dividing each pixel value to 255.The pixel value ranges from 0 to 255 for each the\nchannels (RGB). Dividing it by 255 is necessary to normalize it to 0 to 1 range.\n* ```Step 4:``` Flatten all the images into a vector matrix\n* ```Step 5:``` Shuffled the train dataset for equal distribution of the data for splitting\n* ```Step 6:``` Split the data into three sets - train, test, and validation. This is undergone to avoid data overfitting and to increase the model accuracy score\n\n```CNN graph architecture based on the compiled model```\n![cnn](preview/CNN.png)\n\n## Traning the model by using the train dataset\nEpoch 1/60\n52/52 [==============================] - 17s 318ms/step - loss: 1.7310 - accuracy: 0.2291 - val_loss: 1.7209 - val_accuracy: 0.2467\nEpoch 2/60\n52/52 [==============================] - 6s 107ms/step - loss: 1.7051 - accuracy: 0.2598 - val_loss: 1.6693 - val_accuracy: 0.2349\nEpoch 3/60\n52/52 [==============================] - 4s 85ms/step - loss: 1.6228 - accuracy: 0.2892 - val_loss: 1.5717 - val_accuracy: 0.3482\nEpoch 4/60\n52/52 [==============================] - 5s 96ms/step - loss: 1.5400 - accuracy: 0.3636 - val_loss: 1.5166 - val_accuracy: 0.3449\nEpoch 5/60\n52/52 [==============================] - 5s 93ms/step - loss: 1.4760 - accuracy: 0.3879 - val_loss: 1.4331 - val_accuracy: 0.4297\nEpoch 6/60\n52/52 [==============================] - 5s 91ms/step - loss: 1.4269 - accuracy: 0.4342 - val_loss: 1.3399 - val_accuracy: 0.4749\nEpoch 7/60\n52/52 [==============================] - 5s 92ms/step - loss: 1.3674 - accuracy: 0.4600 - val_loss: 1.3171 - val_accuracy: 0.4760\nEpoch 8/60\n52/52 [==============================] - 5s 91ms/step - loss: 1.3747 - accuracy: 0.4561 - val_loss: 1.2554 - val_accuracy: 0.5385\nEpoch 9/60\n52/52 [==============================] - 5s 92ms/step - loss: 1.2953 - accuracy: 0.4943 - val_loss: 1.2450 - val_accuracy: 0.5167\nEpoch 10/60\n52/52 [==============================] - 5s 90ms/step - loss: 1.2335 - accuracy: 0.5361 - val_loss: 1.1797 - val_accuracy: 0.5469\nEpoch 11/60\n52/52 [==============================] - 5s 92ms/step - loss: 1.1972 - accuracy: 0.5508 - val_loss: 1.1494 - val_accuracy: 0.5731\nEpoch 12/60\n52/52 [==============================] - 4s 86ms/step - loss: 1.1498 - accuracy: 0.5658 - val_loss: 1.1558 - val_accuracy: 0.5714\nEpoch 13/60\n...\nEpoch 59/60\n52/52 [==============================] - 4s 75ms/step - loss: 0.2195 - accuracy: 0.9278 - val_loss: 0.1807 - val_accuracy: 0.9526\nEpoch 60/60\n52/52 [==============================] - 4s 76ms/step - loss: 0.2202 - accuracy: 0.9296 - val_loss: 0.2046 - val_accuracy: 0.9308\n\n## Results\nThe image below shows the results by comparing predictions with the original garbage labels. As can be seen, all images were correctly predicted. The image classfied as ```cardboard``` has the probability of ```99%```, ```glass 87%```, ```metal 99%```, ```paper 96%```, ```plastic 83%```, and ```trash with 98%```.\n\n![results](preview/results.png)\n\n## License\nThis project is [MIT](LICENSE) Licensed\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpizaariaaa%2Fgarbage-classification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpizaariaaa%2Fgarbage-classification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpizaariaaa%2Fgarbage-classification/lists"}