How zinhlemm/track-my-impact works
Project Type and Purpose
• This is a full-stack, single-page web application (built with Streamlit) that leverages a pre-trained Convolutional Neural Network (Keras) to classify household waste images and compute the environmental impact (CO₂, water, energy savings) of correct disposal.
High-Level Components
a. Streamlit Frontend
• The UI layer in waste_classifier/classify.py and Streamlit app code that handles user image upload and displays results.
b. Classification Engine (Backend)
• Core logic in waste_classifier/classifier.py plus model files (waste_model.keras, classnames.json).
• Prediction pipeline: load model → preprocess image → infer class → return label and confidence.
c. Impact Calculator
• Reads data/emission_factors.json to map predicted class to environmental savings.
• Business logic lives alongside the classifier or as part of the same module.
d. Data Storage
• Raw and processed datasets under dataset/ and dataset/split/ (train/val/test) for training and testing.
• Model artifacts in waste_classifier/model/.
• Static lookup files (data/emission_factors.json).
e. Preprocessing & Training Scripts
• scripts/split_dataset.py for dataset partitioning.
• waste_classifier/train_waste_classifier.py to train or fine-tune the CNN.
f. Dependencies & Deployment
• requirements.txt lists Streamlit, TensorFlow/Keras, PIL/OpenCV, etc.
• No external microservices—this is a self-contained Python app.
Relationships & Data Flow
1. User uploads image in the Streamlit UI.
2. Frontend sends the image to the Classification Engine.
3. Engine loads the .keras model and classnames, preprocesses the image, and outputs a class prediction.
4. Impact Calculator module looks up emission factors in emission_factors.json.
5. Combined results (class + CO₂/water/energy savings) return to the UI for display.
6. (Optional for training) Data preprocessing scripts feed into the Training Script, outputting an updated model artifact.
Architectural Patterns & Design Principles
• MVC-style separation:
• View = Streamlit UI
• Controller = classification & calculation logic
• Model = serialized Keras model + data artifacts
• Single-process monolith using Python modules
• Clear separation of concerns: data (JSON, dataset folders), model (Keras), UI (Streamlit), scripts (preprocessing & training)