How tamilselvan-sde/casting-defect-detection- works
Project type and purpose
• This is a machine-learning–powered web application (“Casting Defect Detection”) built with Python and Streamlit.
• Purpose: allow users to upload images of casting components, run a quantized CNN (TensorFlow Lite) model to detect “defective” vs. “non-defective,” and display results in a browser.
File-structure overview
• Top-level files:
• app.py – the Streamlit application entry point (UI + inference logic)
• cnn_model_quantized.tflite – the pre-trained, quantized CNN model file
• requirements.txt – Python dependencies for app & ML
• vibration_damper_failure_detection.ipynb – a Jupyter notebook for related failure-detection experiments (auxiliary)
• .devcontainer/ – VS Code Dev Container configuration for a reproducible development environment
• No separate “frontend” vs. “backend” repo; it’s a single Python monolith handling both UI and inference.
Key components
a. External User & Browser
• The user interacts by visiting the Streamlit URL, uploading images.
b. Streamlit Web UI Layer (app.py)
• Handles HTTP requests, image upload widget, display elements.
c. Inference Engine / Business Logic
• In app.py: loads the TFLite model, preprocesses the image, runs inference, post-processes predictions.
d. Model Artifact Storage
• The cnn_model_quantized.tflite file stored on disk (or bundled in container).
e. Development & Deployment Environment
• VS Code Dev Container (Docker) for local dev; optionally hosted on Streamlit Cloud or another server.
f. (Optional) Experimentation Notebook
• Jupyter notebook used for data exploration & prototyping.
Component relationships & data flow
1) User → Browser: open the app URL
2) Browser → Streamlit UI: uploads image
3) UI → Business Logic: passes image to inference module
4) Inference Module → Model File: loads .tflite
5) Model File → Inference Module: returns prediction
6) Inference Module → UI: returns classification & metrics
7) UI → Browser: renders results
Architectural patterns & design principles
• Single-process, layered monolith: UI, application logic, and model inference co-located in app.py
• Containerization: Dev Container for consistent environment, matching production
• Separation of concerns: keep preprocessing, inference, and presentation in discrete code blocks
Technologies & frameworks
• Streamlit (UI)
• Python (app logic)
• TensorFlow Lite (inference)
• Docker / Dev Container (development environment)
• GitHub (source control)
• (Optional deployment) Streamlit Cloud or any Docker-compatible host