Skip to content

chengwanru/Garbage-sorting-program

Repository files navigation

Garbage Classification App

A Python desktop application that uses AI-powered image recognition to classify household waste into different categories.

Python

Demo

Welcome screen

Initial state

Classification example 1

Classification example 2

Overview

This application helps users identify and classify household garbage into four main categories:

Category Examples
Recyclable Paper, plastic bottles, metal cans, glass
Food Waste Organic/compostable materials
Dry Garbage Non-recyclable, non-hazardous waste
Hazardous Batteries, chemicals, electronics

Built as a learning project to explore cloud APIs and image recognition technology.

Tech Stack

  • Frontend: Tkinter (Python GUI)
  • Backend: Python 3.7+
  • Image Processing: Pillow (PIL)
  • Cloud Services: Alibaba Cloud (OSS + Vision API)
  • Data Storage: CSV (local cache)

Installation

Prerequisites

  • Python 3.7 or higher
  • Alibaba Cloud account with OSS and Image Recognition API enabled

Setup

1. Clone the repository

git clone https://github.com/chengwanru/Garbage-sorting-program.git
cd Garbage-sorting-program

2. Install dependencies

pip install -r requirements.txt

3. Configure API credentials

cp config.py.example config.py

Edit config.py with your Alibaba Cloud credentials

4. Run the application

python code.py

Usage

  1. Launch the app - a welcome screen appears for 5 seconds
  2. Click "Select Picture" to choose an image file
  3. Preview appears in the center of the window
  4. Click "Classification" to analyze the image
  5. Result displays below the buttons (cached for future use)

How It Works

The application follows a simple workflow:

  1. User selects an image from their local computer
  2. System checks if the image was previously classified (CSV cache)
  3. If not cached, the image is uploaded to Alibaba Cloud OSS
  4. Cloud Vision API analyzes and classifies the image
  5. Results are translated from Chinese to English and displayed
  6. Classification is saved locally to avoid redundant API calls

Key Features:

  • Local file selection via file dialog
  • Cloud-based image processing
  • Automatic result caching to reduce API costs
  • Real-time image preview

Development Notes

API Cost Management

Implemented CSV caching to store results and avoid redundant API calls. Each image is only classified once.

Language Translation

API returns Chinese category names which are automatically translated to English using a mapping dictionary.


Made with Python

About

That program is aim to help people sorting garbage.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages