How gamal1osama/garbage-classifier works
Project Type and Purpose
• This is a full-stack ML application for real-time image classification of garbage into ten categories.
• It combines a web-based UI (Gradio) with backend inference logic (Python + TensorFlow) and two interchangeable model architectures (custom CNN and fine-tuned ResNet-101v2).
File Structure
• Top-level:
• .gradio/ → Gradio SSL certificates and UI config
• CNN/ → Jupyter notebook and training artifacts for the custom CNN
• Resnet_101v2/ → Jupyter notebook, model file (.keras), and training history for ResNet-101v2
• Deployment/app.py → Main application entrypoint running the Gradio interface and inference logic
• requirements.txt → Python dependencies
• Pattern: Monolithic service with pluggable model submodules, served via a single Gradio app.
README for Additional Insights
• Key technologies: Python 3.8+, TensorFlow 2.8+, Gradio 3.x
• Two ML pipelines (CNN vs. ResNet-101v2) selectable at runtime
• Real-time image processing and classification with disposal recommendations
• Live deployment on Hugging Face Spaces
a. Components:
1. Client UI (Web Browser)
2. Gradio Frontend
3. app.py Backend Controller
4. Model Manager (loads either CNN or ResNet)
5. TensorFlow Inference Engine
6. Model Artifacts Storage (./CNN/details, ./Resnet_101v2/)
7. Disposal Recommendation Module (simple rules triggered by classification)
8. External Demo Host (Hugging Face Space) – optional external endpoint
b. Interactions:
• Browser → Gradio Frontend: Upload image & select model
• Gradio Frontend → app.py: REST / WebSocket call
• app.py → Model Manager: load selected model if not in memory
• Model Manager → Model Artifacts Storage: read .keras or serialized weights
• Model Manager → TensorFlow: perform inference
• TensorFlow → app.py: return class probabilities
• app.py → Disposal Module: map class to disposal instructions
• app.py → Gradio Frontend: send back results and recommendations
• Gradio Frontend → Browser: render classification and advice
• (Optional) app.py → Hugging Face API for metrics/event logging
c. Architectural Patterns & Principles:
• Single-process, pluggable modules (strategy pattern for model selection)
• Clear separation: UI (view), app.py (controller), model artifacts (data)
• Use of dependency files (requirements.txt) for reproducibility
d. Key Technologies:
• Python with Gradio for UI
• TensorFlow/Keras for model inference
• Jupyter Notebooks for experimentation (CNN/ResNet)
• File-based model storage