Micro_component_dataset / PROJECT_CONTEXT_AND_ACTION_PLAN.md
FaustDerLegende's picture
Upload folder using huggingface_hub (part 53)
ff85f82 verified
|
Raw History Blame Contribute Delete
8.84 kB
# E-Waste PCB Component Purity & Cannibalization Index: Project Context, System Architecture & Master Action Plan
## 1. Project Overview & Business Context
The **Component Purity & Cannibalization Index** is an edge-AI system built for Kabadiwala Connect (e-waste recycling platform). It detects real-time, on-device PCB cannibalization (the illicit stripping of valuable components like CPU sockets, gold edge connector fingers, IC microchips, and SMD tantalum capacitors) to:
1. Calculate a dynamic **Board Integrity Score (BIS)**.
2. Emit **8-language vernacular voice warnings** to scrap collectors for fair purchasing price adjustments.
3. Propagate component integrity data across the **Collector β†’ Dealer β†’ Recycler** supply chain to catch mid-chain cannibalization fraud.
---
## 2. Current Project State & Progress Summary
| Category | Current Status | Details & Artifacts |
| :--- | :--- | :--- |
| **Dataset Size** | **3,923 Normalized JPEGs** | Located in `data/images/` and `data/annotated_auto/images/` (6,864 total tracked). Average resolution: $1315 \times 1029\text{ px}$. |
| **Auto-Annotation** | **6,377 Draft Bounding Boxes** | Auto-labeled across all 4,303 image files via YOLO-World zero-shot model (`pipeline/auto_annotate.py`, `conf=0.015`). |
| **Dataset Spec** | **YOLO Format Ready** | Specification saved to [`data/splits/data.yaml`](file:///home/taruns/Downloads/scraper/data/splits/data.yaml). Summary in [`data/annotated_auto/auto_annotation_summary.json`](file:///home/taruns/Downloads/scraper/data/annotated_auto/auto_annotation_summary.json). |
| **Updated Taxonomy** | **7 Fine-Grained Classes** | Defined in [`config/taxonomy.yaml`](file:///home/taruns/Downloads/scraper/config/taxonomy.yaml) (separates fraud desoldered pads from factory empty pads). |
| **Integrity Engine** | **Track B Complete & Tested** | Purity Engine (`purity_engine/`) with form-factor profiles, scrap grade pricing floors, and 8-language voice alerts. |
| **Pipeline Tests** | **20 / 20 Passed** | Full test suite ([`tests/test_purity_assay.py`](file:///home/taruns/Downloads/scraper/tests/test_purity_assay.py) & [`tests/test_pipeline.py`](file:///home/taruns/Downloads/scraper/tests/test_pipeline.py)) fully compliant. |
---
## 3. Architecture & Dual-Track Execution Strategy
Development is decoupled into two parallel tracks linked by a frozen contract ([`model_contract.md`](file:///home/taruns/Downloads/scraper/implementation_plan_component_purity_index.md#L61)):
```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ model_contract.md (Frozen Schema) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Track A: Model & Dataset β”‚ β”‚ Track B: Application & Integration β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β€’ 7-Class Refined Taxonomy β”‚ β”‚ β€’ `MockModelClient` for Dev/Testing β”‚
β”‚ β€’ Multi-Scale YOLOv8 Training β”‚ β”‚ β€’ Integrity Engine (`purity_assay.py`) β”‚
β”‚ β€’ Focal Loss for Desoldered β”‚ β”‚ β€’ Offline Pre-Recorded Audio Warnings β”‚
β”‚ β€’ TFLite INT8 Quantization β”‚ β”‚ β€’ Collector Lite & Recycler Portal β”‚
β”‚ β€’ Real-World Test Evaluation β”‚ β”‚ β€’ BIS-Delta Fraud Discrepancy UI β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β–Ό
Swap Mock for Quantized Model (`TFLiteModelClient`)
(1-Line Config Change)
```
---
## 4. System Requirements & Architectural Adjustments
Based on technical analysis and field realities, the following system-level changes are enforced:
### A. Edge Hardware & Memory Optimization (Low-End Android 2GB–3GB RAM)
* **Sequential Model Execution**: Running the 21-class category model and YOLOv8 micro-model simultaneously triggers browser tab memory crashes.
* **Fix**: Enforce explicit tensor disposal (`model.dispose()`) after Stage 1 classification before loading Stage 2 micro-component detection.
### B. Taxonomy Refinement (Eliminating False Fraud Signals)
* **Fix**: Split generic desoldered footprints into:
1. `forcibly_desoldered_pad`: Exposed pads with jagged solder peaks, torn traces, or blowtorch/burnt flux residue (**fraud signal**).
2. `factory_unpopulated_pad`: Clean silkscreen outline with smooth solder dots left unpopulated from factory (**NOT fraud**).
3. `occluded_region`: Footprints covered by heatsinks, metal shields, or thick dust.
### C. Dynamic Scrap Grade Pricing Floor
* **Fix**: Replace rigid 35% hardcoded floor with category scrap grade floors:
$$\text{Adjusted Price} = \text{Base Price} \times \left( \text{Floor}_{\text{category}} + (1 - \text{Floor}_{\text{category}}) \times \frac{\text{BIS}}{100} \right)$$
* Server/GPU PCBs: $\text{Floor} = 0.15$
* Desktop PCBs: $\text{Floor} = 0.30$
* Low-grade Power PCBs: $\text{Floor} = 0.60$
### D. Multi-Angle 2-Sided Inspection Protocol
* **Fix**: Standardize a 2-photo workflow (Front Top-Down + Reverse Bottom-Down / Edge) in Collector Lite to inspect both sides of the PCB.
### E. Supply Chain Fraud Tolerance Bands
* **Fix**: Update Recycler Portal intake discrepancy bands to:
* $< 12\%$ BIS Drop $\rightarrow$ Normal capture variance (Pass).
* $12\text{--}25\%$ BIS Drop $\rightarrow$ Advisory Warning / Discrepancy Flag.
* $> 25\%$ BIS Drop $\rightarrow$ Critical Fraud Alert & CPCB Form 6 PDF Audit Log Entry.
### F. Offline Vernacular Audio Reliability
* **Fix**: Standardize pre-recorded `.opus` audio playback via Service Worker `CacheStorage` as a fallback when Web Speech API regional voice packs are missing offline.
---
## 5. Master Plan of Action (Step-by-Step Roadmap)
### Phase 1: Baseline Model Training (Track A)
- [x] Auto-annotate dataset with 3,130 draft boxes (`pipeline/auto_annotate.py`).
- [ ] Fine-tune baseline **YOLOv8n / YOLOv8s** on `data/annotated_auto/data.yaml` (`imgsz=960` or `1280`).
- [ ] Evaluate per-class mAP@50 and fraud recall on `forcibly_desoldered_pad`.
- [ ] Quantize model to TFLite INT8 ($<15\text{ MB}$, target $<1\text{s}$ latency).
### Phase 2: Incremental Harvest & Synthetic Data (Optional Extension)
- [ ] Execute optional incremental scraper batch (~500–1,000 images) using updated [`config/queries.yaml`](file:///home/taruns/Downloads/scraper/config/queries.yaml).
- [ ] Apply CutMix / Copy-Paste synthetic desoldered pad data synthesis during training.
### Phase 3: Purity Engine Module Build (Track B)
- [ ] Build `purity_engine/model_client.py` (`MockModelClient` & `TFLiteModelClient`).
- [ ] Build `purity_engine/purity_assay.py` (Form-factor baseline matching + dynamic scrap pricing formula).
- [ ] Build `purity_engine/vernacular_voice.py` (Web Speech API + `.opus` fallback).
### Phase 4: App Integration & End-to-End Verification
- [ ] Extend Collector Lite (`mobile/kabadiwala-lite.html`) with 2-photo workflow & inline BIS display.
- [ ] Extend Recycler Portal (`recycler-dashboard-frontend/`) with BIS-delta view ($12\% / 25\%$ flags).
- [ ] Run automated test suite (`tests/test_purity_assay.py`, `tests/test_bis_delta_api.py`).
---
## 6. Key Configuration & Pipeline Commands Quick Reference
* **Run Automated Tests**:
```bash
.venv/bin/python -m pytest
```
* **Run Auto-Annotation Script**:
```bash
.venv/bin/python pipeline/auto_annotate.py
```
* **Run Incremental Web Scraper**:
```bash
.venv/bin/python scraper.py harvest
```
* **Dataset Location**: `data/annotated_auto/`