How dddanielliu/trash-classify works
Project Overview & Purpose
• This is a full-stack application whose primary goal is to allow users to upload pictures of trash so that an integrated machine learning model can classify them into one of eight trash categories.
• The project has two main parts: a Django-based website (in the “website” directory) handling user interactions, image uploads, and administrative functions, and a model component (in the “model” directory) that contains the classification logic, the trained models, and training scripts.
Analyzing the File Structure
• At the top level, you have configuration files (.gitignore, compose.yaml, README.md) which indicate container orchestration via Docker Compose.
• The “model” directory includes:
• Python scripts (ClassifyInterface.py, main.py) to interface with the machine learning model.
• Training related materials (train.ipynb, training logs, trained Keras model files).
• A Dockerfile for containerizing the model service.
• The “website” directory houses a Django project:
• Django project files (manage.py, settings.py, urls.py, wsgi.py/asgi.py).
• Static assets (CSS, JavaScript, images, PDFs) and Django templates for the UI.
• An “admin” section and defined routes such as home, about, display, and admin pages.
• A SQLite database file (db.sqlite3) which indicates persistence for the web side.
Key Architectural Elements to Capture
a. Main Components:
• User Interface Frontend: The website (Django based) that handles HTTP requests, image uploads, and displays classification results.
• Backend Web Application: The Django application managing views, models, templates, and authentication (staff/admin features).
• Machine Learning (ML) Service: The “model” component responsible for classifying images. It encapsulates the classification logic and may also be involved in training/updating the model.
• Persistence: SQLite database (within the website container) that stores user data and possibly logs the classification outputs.
• Supporting Infrastructure: Docker Compose configuration that orchestrates separate containers. Also note the shared volume (“images” directory) used for storing uploaded pictures.
b. Relationships & Interactions:
• The user accesses the web application via a browser (HTTP/HTTPS).
• When a picture is uploaded, the website backend passes the image data to the ML service component. This could be through an API call or an internal library call, depending on the integration implemented.
• The ML service processes the image and returns the predicted class label, which is then rendered on one of the website pages (e.g., at the display page).
• The Docker Compose setup ensures that the website container and the ML service container can communicate with each other using internal networking.
• There is an upload directory (or mounted volume) for image storage and persistence for logs and trained models.
c. Architectural Patterns & Design Principles:
• Separation of concerns: The system distinctly separates the web interface and ML logic, making it easier to maintain or scale each independently (microservices-like separation).
• Containerization: Both components have Dockerfiles that allow them to run in isolated environments managed by Docker Compose.
• MVC (in the Django side), where the views interact with models and templates to render the UI.
• The provision for re-training the model (using Jupyter Notebook and training logs) is also a key design element, showing that the system is designed to support updates to the ML component.
d. Relevant Technologies & Frameworks:
• Django Web Framework (Python) for the website.
• SQLite for the website’s database.
• Keras/TensorFlow for the machine learning model and training processes.
• Docker (and Docker Compose) for container orchestration.
• Likely JavaScript/CSS for frontend interactions in the “website/static” folder.