{"id":27645988,"url":"https://github.com/gbr-rl/smartsort-cam","last_synced_at":"2026-04-09T22:59:23.512Z","repository":{"id":288448829,"uuid":"963230456","full_name":"GBR-RL/SmartSort-CAM","owner":"GBR-RL","description":"End-to-end industrial part classification system using Blender-generated synthetic data, ConvNeXt, Grad-CAM, and FastAPI — fully containerized with Docker for real-time inference.","archived":false,"fork":false,"pushed_at":"2025-04-17T22:31:57.000Z","size":41270,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-24T01:14:17.304Z","etag":null,"topics":["blender","computer-vision","convnext","docker","explainable-ai","fastapi","grad-cam","industrial-classification","mlops","synthetic-data","uvicorn"],"latest_commit_sha":null,"homepage":"https://gbr-rl.github.io/SmartSort-CAM/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GBR-RL.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-09T11:07:21.000Z","updated_at":"2025-04-17T22:32:00.000Z","dependencies_parsed_at":"2025-04-18T06:20:01.285Z","dependency_job_id":null,"html_url":"https://github.com/GBR-RL/SmartSort-CAM","commit_stats":null,"previous_names":["gbr-rl/smartsort-cam"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GBR-RL%2FSmartSort-CAM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GBR-RL%2FSmartSort-CAM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GBR-RL%2FSmartSort-CAM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GBR-RL%2FSmartSort-CAM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GBR-RL","download_url":"https://codeload.github.com/GBR-RL/SmartSort-CAM/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250540917,"owners_count":21447427,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blender","computer-vision","convnext","docker","explainable-ai","fastapi","grad-cam","industrial-classification","mlops","synthetic-data","uvicorn"],"created_at":"2025-04-24T01:14:55.279Z","updated_at":"2026-04-09T22:59:23.486Z","avatar_url":"https://github.com/GBR-RL.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SmartSort-CAM: Intelligent Industrial Part Classification with Grad-CAM Explainability\n\n[![Docker](https://img.shields.io/badge/docker-ready-blue?logo=docker)](https://hub.docker.com/)\n[![FastAPI](https://img.shields.io/badge/fastapi-async--api-success?logo=fastapi)](https://fastapi.tiangolo.com/)\n[![Made with Blender](https://img.shields.io/badge/rendered%20with-blender-orange?logo=blender)](https://www.blender.org/)\n[![License: MIT](https://img.shields.io/badge/license-MIT-green)](./LICENSE)\n[![Python](https://img.shields.io/badge/python-3.10+-blue.svg?logo=python)](https://www.python.org/downloads/release/python-3100/)\n\n![SmartSort-CAM Banner](https://raw.githubusercontent.com/gbr-rl/SmartSort-CAM/main/docs/banner.png)\n\nSmartSort-CAM is a comprehensive computer vision pipeline designed to classify industrial parts (bolts, nuts, washers, gears, bearings etc.) using a ConvNeXt-based deep learning model. The system includes a Blender-based synthetic dataset generator, a REST API for deployment, Grad-CAM visualization for explainability, Docker integration, and detailed exploratory analysis.\n\n---\n\n## Project Structure Overview\n\n```plaintext\nSmartSort-CAM/\n├── app/                        # REST API handler\n│   └── main.py                # Inference API client (calls FastAPI endpoint)\n│\n├── cv_pipeline/               # Core CV logic\n│   └── inference.py           # Model loading, Grad-CAM, and FastAPI server\n│\n├── assets/                    # Blender rendering assets\n│   ├── hdri/                  # HDR lighting maps\n│   ├── textures/              # Steel surface textures\n│   └── stl/                   # 3D models of industrial parts\n│\n├── data/                      # Synthetic dataset samples and label CSV\n│   └── part_labels.csv\n│   ├── test_images/\n│   ├── dataset_samples/\n│\n├── outputs/                   # Inference results\n│   ├── predictions/           # JSON output from API inference\n│   └── visualizations/        # Grad-CAM image overlays\n│\n├── notebooks/                 # Exploratory and training notebooks\n│   ├── exploratory.ipynb      # EDA of generated dataset\n│   └── model_training.ipynb   # Training \u0026 evaluation of ConvNeXt\n│\n├── scripts/                   # Dataset rendering logic\n│   └── Render_dataset.py      # Synthetic render generator using Blender\n│\n├── docker/                    # Containerization support\n│   ├── Dockerfile\n│   └── Makefile\n│\n├── requirements.txt           # Python dependencies\n├── .gitignore\n└── README.md\n```\n\n---\n\n## Synthetic Dataset Generation with Blender\n\nLocated in `scripts/Render_dataset.py`, the rendering pipeline utilizes:\n\n- **Blender's Cycles Renderer** for high-fidelity image generation.\n- **Randomized lighting (HDRI)** via `setup_hdri_white_background()`.\n- **Random camera angles \u0026 object jitter** using `setup_camera_aimed_at()` and `apply_positional_jitter()`.\n- **Steel texture application** to STL meshes using `import_stl()`.\n- **HDRI strength and exposure control** to simulate real-world lighting variance.\n- **Positional randomness and material reflectivity** to increase dataset diversity.\n\nThe output directory is organized by class and tag (e.g., `data/dataset_samples/bolt/good/bolt_001.png`).\n\nFinally, the script auto-generates a CSV:\n```\nfilepath,label\nbolt/good/bolt_001.png,bolt\n...\n```\n\nThis CSV is used for model training.\n\n---\n\n## Exploratory Data Analysis (EDA)\n\nFound in `notebooks/exploratory.ipynb`, this notebook analyzes:\n- Class distribution bar plots\n- Image shape distributions\n- Random render samples\n- Augmentation previews\n- Trained model sanity checks on generated images\n\nThis helped verify:\n- Data cleanliness\n- Label balance\n- Visual consistency across categories\n\n---\n\n## Model Training: ConvNeXt + Mixed Precision(FP16)\n\nDefined in `notebooks/model_training.ipynb`:\n\n- **Backbone**: `convnext_large` from TIMM\n- **Image Size**: 512x512\n- **Loss**: CrossEntropy\n- **Optim**: AdamW\n- **Regularization**: Dropout (0.3), weight decay (1e-5)\n- **Augmentations**: Flip, rotation, color jitter\n- **Split**: 80/20 train-validation split\n\n### Results:\n- **Validation Accuracy**: 100% on synthetic validation set\n- **F1 / Precision / Recall**: All 1.0 (confirmed clean split)\n- **Domain shift test (blur, noise, rotation)**: ~99.5% accuracy with high confidence\n\n---\n\n## Inference Pipeline: FastAPI + Grad-CAM\n\nFound in `cv_pipeline/inference.py`, the pipeline offers:\n\n- **API Endpoint**: `/predict`\n- **Input**: Multipart image upload\n- **Outputs**:\n  - `predicted_class`\n  - `confidence`\n  - `entropy`\n  - `top-3 predictions`\n  - `gradcam_overlay` (base64 PNG)\n\n### Grad-CAM Details:\n- Hooked into the last `conv_dw` block\n- Produces pixel-level heatmaps\n- Visualizations show part regions influencing predictions\n\n---\n\n## Outputs: Results and Visuals\n\nAll inference outputs are saved to `outputs/`:\n- Grad-CAM overlays: `outputs/visualizations/gradcam_bolt.png`\n- API JSONs: `outputs/predictions/result_bolt.json`\n\nThese can be used for audits, reports, or additional UI visualization.\n\n---\n\n## Docker + Automation\n\nIn `docker/`, you’ll find:\n\n### Dockerfile (CUDA compatible)\n```dockerfile\nFROM pytorch/pytorch:2.1.0-cuda11.8-cudnn8-runtime\nWORKDIR /app\nCOPY . /app\nRUN pip install --no-cache-dir -r requirements.txt\nEXPOSE 8000\nCMD [\"uvicorn\", \"cv_pipeline.inference:app\", \"--host\", \"0.0.0.0\", \"--port\", \"8000\"]\n```\n\n### Makefile\n```makefile\nmake build        # Builds Docker image\nmake run-gpu      # Runs inference server with GPU\nmake stop         # Stops all containers\n```\n\n## 🚀 Getting Started\n\n```bash\n# Clone repo\nhttps://github.com/gbr-rl/SmartSort-CAM\n\n# Build Docker image\nmake build\n\n# Run container (GPU)\nmake run-gpu\n\n# Send test request\npython app/main.py bolt.png\n```\n\n---\n\n## 📬 Contact\nI’m excited to connect and collaborate!  \n- **Email**: [gbrohiith@gmail.com](mailto:your.email@example.com)  \n- **LinkedIn**: [https://www.linkedin.com/in/rohiithgb/](https://linkedin.com/in/yourprofile)  \n- **GitHub**: [https://github.com/GBR-RL/](https://github.com/yourusername)\n\n---\n\n## 📚 License\nThis project is open-source and available under the [MIT License](LICENSE).  \n\n---\n\n🌟 **If you like this project, please give it a star!** 🌟\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgbr-rl%2Fsmartsort-cam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgbr-rl%2Fsmartsort-cam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgbr-rl%2Fsmartsort-cam/lists"}