How garvitjoshi1/inspectra works
Purpose and Entry Points
Inspectra is a computer-vision defect-inspection project spanning dataset preparation, model training, evaluation, ONNX export, and local inference deployment. The executable serving surface is deployment/api.py, supported by deployment/inference.py and deployment/model_registry.py. The notebook sequence (notebooks/01_dataset_inspection.ipynb through notebooks/09_deployment.ipynb) is the primary experiment workflow.
Data Preparation and Experiment Workflow
The project uses public industrial-inspection datasets covering cracks, PCB defects, steel defects, bottles, and welding defects. Dataset inspection, cleaning, and preparation are staged in notebooks/01_dataset_inspection.ipynb, notebooks/02_data_cleaning.ipynb, and notebooks/03_data_preparation.ipynb. Cleaning outcomes are persisted in reports/dataset_cleaning_report.json, creating a boundary between raw data work and downstream training.
Model Families and Training
Two model tracks are evident:
• Object-detection models for bottle and PCB inspection, with baseline and fine-tuned checkpoints under experiments/bottle/baseline/baseline/weights/best.pt, experiments/pcb/baseline/baseline/weights/best.pt, and experiments/finetuning/experiment_config.json.
• A road/defect classification-style ResNet-18 track, with baseline and tuned weights at models/road/baseline_resnet18.pt and models/road/finetuned/resnet18_finetuned.pt.
Training and fine-tuning are notebook-driven through notebooks/04_baseline_training.ipynb and notebooks/06_fine_tuning.ipynb; model artifacts are durable experiment outputs rather than dynamically trained by deployment.
Evaluation and Release Selection
Baseline, fine-tuned, and final-test results are materialized as CSV/JSON artifacts. Evaluation is performed in notebooks/05_evaluation.ipynb, while release-candidate comparison and final validation are recorded in experiments/final_testing/deployment_candidates.csv, experiments/final_testing/final_results.csv, and experiments/final_testing/final_results.json. This forms the selection boundary between experimental weights and deployable models.
Export and Model Metadata
Selected models are converted to ONNX for runtime portability via notebooks/08_model_export.ipynb. Deployable exports are located at experiments/exports/bottle/bottle_finetuned.onnx, experiments/exports/pcb/pcb_finetuned.onnx, and experiments/exports/road/road_resnet18_finetuned.onnx. experiments/exports/export_manifest.json tracks exported artifacts, while deployment/model_metadata.json supplies deployment-facing model information.
Deployment Runtime
deployment/api.py exposes inference operations; deployment/inference.py encapsulates model loading, preprocessing, execution, and prediction formatting; deployment/model_registry.py resolves available model variants and their metadata/artifact locations. The intended control flow is request/input → API → registry-selected model → inference runtime → structured prediction response. ONNX is the key deployment boundary, separating training-framework checkpoints (.pt) from portable inference artifacts (.onnx).
Infrastructure and External Dependencies
The repository is primarily a local Python ML workflow, with dependencies declared in requirements.txt and pyproject.toml. It relies on externally sourced Kaggle and Mendeley datasets rather than an in-repo data store. No cloud infrastructure, database, message broker, or frontend is represented in the tree; artifact files and JSON/CSV manifests serve as the project’s persistence and model-governance layer.
Main entry points: best.pt Training checkpoints · 08_model_export.ipynb ONNX export · model_registry.py Model registry · inference.py Inference runtime
Components 18
Experiment workflow
- Public inspection datasets · Kaggle and Mendeley sourced defect datasets.
- Dataset inspection
notebooks/01_dataset_inspection.ipynb - Data cleaning
notebooks/02_data_cleaning.ipynb - Data preparation
notebooks/03_data_preparation.ipynb - Baseline training
notebooks/04_baseline_training.ipynb - Fine-tuning
notebooks/06_fine_tuning.ipynb - Evaluation
notebooks/05_evaluation.ipynb - ONNX export
notebooks/08_model_export.ipynb
Model governance
- Cleaning report · Persisted quality boundary for downstream work.
reports/dataset_cleaning_report.json - Training checkpoints · Detection and ResNet-18 baseline and tuned weights.
experiments/bottle/baseline/baseline/weights/best.pt - Release validation results · Compares deployment candidates and records final validation.
experiments/final_testing/final_results.json - Deployable ONNX models · Portable bottle, PCB, and road model exports.
experiments/exports/bottle/bottle_finetuned.onnx - Export manifest
experiments/exports/export_manifest.json
Local deployment
- Deployment metadata
deployment/model_metadata.json - Inference API · Executable local serving surface.
deployment/api.py - Model registry · Resolves model variants, metadata, and artifact locations.
deployment/model_registry.py - Inference runtime · Loads ONNX models, preprocesses inputs, executes inference, and formats predictions.
deployment/inference.py - Structured prediction
Connections 21
- Public inspection datasets → Dataset inspection: inspect
- Dataset inspection → Data cleaning: inform
- Data cleaning → Cleaning report: persist
- Cleaning report → Data preparation: quality boundary
- Data preparation → Baseline training: prepared data
- Baseline training → Training checkpoints: produce baselines
- Training checkpoints → Fine-tuning: initialize
- Fine-tuning → Training checkpoints: produce tuned weights
- Training checkpoints → Evaluation: evaluate
- Evaluation → Release validation results: record results
- Release validation results → ONNX export: select candidates
- Training checkpoints → ONNX export: selected weights
- ONNX export → Deployable ONNX models: convert
- ONNX export → Export manifest: record exports
- Export manifest → Deployment metadata: deployment inventory
- Inference API → Model registry: resolve variant
- Model registry → Deployment metadata: read metadata
- Model registry → Deployable ONNX models: locate artifact
- Inference API → Inference runtime: submit input
- Inference runtime → Deployable ONNX models: load and execute
- Inference runtime → Structured prediction: format prediction