{"id":13724409,"url":"https://github.com/garythung/trashnet","last_synced_at":"2025-05-07T18:31:48.187Z","repository":{"id":41866984,"uuid":"87667522","full_name":"garythung/trashnet","owner":"garythung","description":"Dataset of images of trash; Torch-based CNN for garbage image classification","archived":false,"fork":false,"pushed_at":"2023-06-02T03:39:01.000Z","size":41622,"stargazers_count":629,"open_issues_count":8,"forks_count":193,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-05-02T15:36:23.742Z","etag":null,"topics":["convolutional-neural-networks","dataset","deep-learning","garbage","image-classification","torch","trash"],"latest_commit_sha":null,"homepage":"","language":"Lua","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/garythung.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}},"created_at":"2017-04-08T22:16:08.000Z","updated_at":"2025-04-30T16:32:25.000Z","dependencies_parsed_at":"2023-09-21T19:57:47.603Z","dependency_job_id":null,"html_url":"https://github.com/garythung/trashnet","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"6fa2b878c6c1b4304b91109070ce0edf9279bb31"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garythung%2Ftrashnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garythung%2Ftrashnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garythung%2Ftrashnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garythung%2Ftrashnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/garythung","download_url":"https://codeload.github.com/garythung/trashnet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252215085,"owners_count":21712915,"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","dataset","deep-learning","garbage","image-classification","torch","trash"],"created_at":"2024-08-03T01:01:56.679Z","updated_at":"2025-05-07T18:31:48.084Z","avatar_url":"https://github.com/garythung.png","language":"Lua","funding_links":[],"categories":["Circular Economy and Waste","Lua","Industrial Ecology","Random Stuff That Doesn't Fit Anywhere"],"sub_categories":["Soil","Circular Economy and Waste","Useful big datasets"],"readme":"# trashnet\nCode (only for the convolutional neural network) and dataset for mine and [Mindy Yang](http://github.com/yangmindy4)'s final project for [Stanford's CS 229: Machine Learning class](http://cs229.stanford.edu). Our paper can be found [here](https://cs229.stanford.edu/proj2016/report/ThungYang-ClassificationOfTrashForRecyclabilityStatus-report.pdf). 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.\n\n## Dataset\nThis 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:\n- 501 glass\n- 594 paper\n- 403 cardboard\n- 482 plastic\n- 410 metal\n- 137 trash\n\nThe 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.\n\nThe 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.\n\n**If you are using the dataset, please give a citation of this repository. The dataset can be downloaded [here](https://huggingface.co/datasets/garythung/trashnet).**\n\n## Installation\n### Lua setup\nWe wrote code in [Lua](http://lua.org) using [Torch](http://torch.ch); you can find installation instructions\n[here](http://torch.ch/docs/getting-started.html). You'll need the following Lua packages:\n\n- [torch/torch7](http://github.com/torch/torch7)\n- [torch/nn](http://github.com/torch/nn)\n- [torch/optim](http://github.com/torch/optim)\n- [torch/image](http://github.com/torch/image)\n- [torch/gnuplot](http://github.com/torch/gnuplot)\n\nAfter installing Torch, you can install these packages by running the following:\n\n```bash\n# Install using Luarocks\nluarocks install torch\nluarocks install nn\nluarocks install optim\nluarocks install image\nluarocks install gnuplot\n```\n\nWe also need [@e-lab](http://github.com/e-lab)'s [weight-init module](http://github.com/e-lab/torch-toolbox/blob/master/Weight-init/weight-init.lua), which is already included in this repository.\n\n### CUDA support\nBecause 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](http://developer.nvidia.com/cuda-downloads).\n\nThen you need to install following Lua packages for CUDA:\n- [torch/cutorch](http://github.com/torch/cutorch)\n- [torch/cunn](http://github.com/torch/cunn)\n\nYou can install these packages by running the following:\n\n```bash\nluarocks install cutorch\nluarocks install cunn\n```\n\n### Python setup\nPython is currently used for some image preprocessing tasks. The Python dependencies are:\n- [NumPy](http://numpy.org)\n- [SciPy](http://scipy.org)\n\nYou can install these packages by running the following:\n\n```bash\n# Install using pip\npip install numpy scipy\n```\n\n## Usage\n\n### Step 1: Prepare the data\nUnzip `data/dataset-resized.zip`.\n\nIf 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.\n\n### Step 2: Train the model\nTODO\n\n### Step 3: Test the model\nTODO\n\n### Step 4: View the results\nTODO\n\n## Contributing\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -m 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request\n\n## Acknowledgments\n- Thanks to the Stanford CS 229 autumn 2016-2017 teaching staff for a great class!\n- [@e-lab](http://github.com/e-lab) for their [weight-init Torch module](http://github.com/e-lab/torch-toolbox/blob/master/Weight-init/weight-init.lua)\n\n## TODOs\n- finish the Usage portion of the README\n- add specific results (and parameters used) that were achieved after the CS 229 project deadline\n- add saving of confusion matrix data and creation of graphic to `plot.lua`\n- rewrite the data preprocessing to only reprocess new images if the dimensions have not changed\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarythung%2Ftrashnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgarythung%2Ftrashnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarythung%2Ftrashnet/lists"}