👻🚮 Use image recognition to know where to dispose of anything.
The API is a Flask application.
Images are classified by a TensorFlow model trained over the ImageNet database.
We use WordNet to map the recognition labels with trash disposal categories from Données Québec.
SnapTrash uses modern tools
- Docker # containers
- Flask # server app
- nltk # natural language processing
- TensorFlow # image classification
- ImageNet # recognition mapping
- Shapely # analysis of geometric objects in the cartesian plane
- GeoPy # geocoding services
- NumPy # array-processing package
- Données Québec # datasets
If you don't want to start the server on your localhost directly, you can use our prepared Dockerfile, which serves the Flask app at port 5005 (make sure this port is exposed on your VM, etc):
# Build images
docker-compose build
# Run containers
docker-compose up -d
# Make any requests at:
http://localhost:5005If you want to install the flask server and the other dependencies and requirements on your local machine, you can do so this way as well:
python3 -m venv snaptrash.venv
source snaptrash.venv/bin/activate
pip install -r requirements.txt
python -c "import nltk; nltk.download('wordnet'); nltk.download('omw')"
cd server/
FLASK_APP='server.py'
flask run --host=0.0.0.0 --port=5005We use the Laval dataset to categorize the various types of trash that should be classified. The types we classify images into are as follows:
- materiaux
- compost
- recyclage
- ordures
- dangereux
We use the datasets from the following cities to help people know where to go to pickup/dropoff their trash:
- Montréal (for pickup information only)
- Québec (for dropoff locations only)
- Sherbrooke (for dropoff locations only)
Get best match in trash categories from a picture
/predict:
HOST='localhost:5005'
FILE='banana.jpeg'
curl -F file=@$FILE $HOST/predictGet best match in trash categories from a WordNet synset ID.
/categories/{wordnet_id}:
HOST='localhost:5005'
SYNSET='banana.n.02'
curl $HOST/categories/$SYNSETGet information regarding waste pickup based on location. You should be in Montreal to obtain the correct pickup information (we use only the Montréal dataset for now) in the form of a GeoLocation Feature.
/pickup-info/<pickup_type>?latitude=<latitude_coordinate>&longitude=<long_coordinate>:
HOST='localhost:5005'
curl $HOST/pickup-info/compost?longitude=-73.56229610000003&latitude=45.4946761When you have dangerous trash, you would probably need to throw it out at a specific dropoff location. This endpoint gets that information for you in the form of a GeoLocation Feature.
/drop-info/dangereux?latitude=46.8921&longitude=-71.195
HOST='localhost:5005'
curl $HOST/drop-info/dangereux?latitude=46.8921&longitude=-71.195We used the following datasets from their respective cities: