trashnet
Dataset of images of trash. Torch-based CNN for garbage image classification.
https://github.com/garythung/trashnet
Category: Industrial Ecology
Sub Category: Circular Economy and Waste
Keywords
convolutional-neural-networks dataset deep-learning garbage image-classification torch trash
Last synced: about 2 hours ago
JSON representation
Repository metadata
Dataset of images of trash; Torch-based CNN for garbage image classification
- Host: GitHub
- URL: https://github.com/garythung/trashnet
- Owner: garythung
- License: mit
- Created: 2017-04-08T22:16:08.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-06-02T03:39:01.000Z (almost 2 years ago)
- Last Synced: 2025-04-25T12:05:24.670Z (2 days ago)
- Topics: convolutional-neural-networks, dataset, deep-learning, garbage, image-classification, torch, trash
- Language: Lua
- Homepage:
- Size: 39.7 MB
- Stars: 627
- Watchers: 27
- Forks: 191
- Open Issues: 8
- Releases: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
README.md
trashnet
Code (only for the convolutional neural network) and dataset for mine and Mindy Yang's final project for Stanford's CS 229: Machine Learning class. Our paper can be found here. The convolutional neural network results on the poster are dated since we continued working after the end of the quarter and were able to achieve around 75% test accuracy (with 70/13/17 train/val/test split) after changing the weight initialization to the Kaiming method.
Dataset
This repository contains the dataset that we collected. The dataset spans six classes: glass, paper, cardboard, plastic, metal, and trash. Currently, the dataset consists of 2527 images:
- 501 glass
- 594 paper
- 403 cardboard
- 482 plastic
- 410 metal
- 137 trash
The pictures were taken by placing the object on a white posterboard and using sunlight and/or room lighting. The pictures have been resized down to 512 x 384, which can be changed in data/constants.py
(resizing them involves going through step 1 in usage). The devices used were Apple iPhone 7 Plus, Apple iPhone 5S, and Apple iPhone SE.
The size of the original dataset, ~3.5GB, exceeds the git-lfs maximum size so it has been uploaded to Google Drive. If you are planning on using the Python code to preprocess the original dataset, then download dataset-original.zip
from the link below and place the unzipped folder inside of the data
folder.
If you are using the dataset, please give a citation of this repository. The dataset can be downloaded here.
Installation
Lua setup
We wrote code in Lua using Torch; you can find installation instructions
here. You'll need the following Lua packages:
After installing Torch, you can install these packages by running the following:
# Install using Luarocks
luarocks install torch
luarocks install nn
luarocks install optim
luarocks install image
luarocks install gnuplot
We also need @e-lab's weight-init module, which is already included in this repository.
CUDA support
Because training takes awhile, you will want to use a GPU to get results in a reasonable amount of time. We used CUDA with a GTX 650 Ti with CUDA. To enable GPU acceleration with CUDA, you'll first need to install CUDA 6.5 or higher. Find CUDA installations here.
Then you need to install following Lua packages for CUDA:
You can install these packages by running the following:
luarocks install cutorch
luarocks install cunn
Python setup
Python is currently used for some image preprocessing tasks. The Python dependencies are:
You can install these packages by running the following:
# Install using pip
pip install numpy scipy
Usage
Step 1: Prepare the data
Unzip data/dataset-resized.zip
.
If adding more data, then the new files must be enumerated properly and put into the appropriate folder in data/dataset-original
and then preprocessed. Preprocessing the data involves deleting the data/dataset-resized
folder and then calling python resize.py
from trashnet/data
. This will take around half an hour.
Step 2: Train the model
TODO
Step 3: Test the model
TODO
Step 4: View the results
TODO
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -m 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request
Acknowledgments
- Thanks to the Stanford CS 229 autumn 2016-2017 teaching staff for a great class!
- @e-lab for their weight-init Torch module
TODOs
- finish the Usage portion of the README
- add specific results (and parameters used) that were achieved after the CS 229 project deadline
- add saving of confusion matrix data and creation of graphic to
plot.lua
- rewrite the data preprocessing to only reprocess new images if the dimensions have not changed
Owner metadata
- Name: Gary Thung
- Login: garythung
- Email:
- Kind: user
- Description:
- Website:
- Location: New York City
- Twitter: garythung
- Company:
- Icon url: https://avatars.githubusercontent.com/u/7055455?u=e02dd0459e996e81e30bddc43a53a9ebb23e953d&v=4
- Repositories: 4
- Last ynced at: 2023-03-25T02:18:24.444Z
- Profile URL: https://github.com/garythung
GitHub Events
Total
- Watch event: 64
- Fork event: 20
Last Year
- Watch event: 64
- Fork event: 20
Committers metadata
Last synced: 5 days ago
Total Commits: 8
Total Committers: 1
Avg Commits per committer: 8.0
Development Distribution Score (DDS): 0.0
Commits in past year: 1
Committers in past year: 1
Avg Commits per committer in past year: 1.0
Development Distribution Score (DDS) in past year: 0.0
Name | Commits | |
---|---|---|
Gary Thung | g****g | 8 |
Committer domains:
Issue and Pull Request metadata
Last synced: 1 day ago
Total issues: 6
Total pull requests: 3
Average time to close issues: about 2 years
Average time to close pull requests: N/A
Total issue authors: 6
Total pull request authors: 3
Average comments per issue: 2.83
Average comments per pull request: 0.33
Merged pull request: 0
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- nhammad (1)
- iamshuvra (1)
- luclt12706 (1)
- AnirudhDagar (1)
- bemoregt (1)
- geom16011 (1)
Top Pull Request Authors
- OctavDM (1)
- altanai (1)
- Sam8239 (1)
Top Issue Labels
Top Pull Request Labels
Score: 6.453624998892692