YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
π E-Waste PCB Component Purity & Cannibalization Index
An Edge-AI system designed for Kabadiwala Connect to detect real-time, on-device PCB component cannibalization (the illicit stripping of valuable components like CPU sockets, gold edge connector fingers, IC microchips, and SMD tantalum capacitors).
The system calculates a dynamic Board Integrity Score (BIS 0β100), applies category scrap grade pricing floors, emits 8-language vernacular voice warnings to scrap collectors, and tracks intake discrepancy tolerance bands ($<12%$ pass, $12\text{--}25%$ advisory, $>25%$ fraud alert) to stop supply chain fraud.
π Repository & Directory Structure
.
βββ README.md # Master project documentation
βββ PROJECT_CONTEXT_AND_ACTION_PLAN.md # Architectural specification & action plan
βββ huggingface_dataset/ # Formatted Hugging Face Hub dataset folder
β βββ README.md # Dataset Card with YAML metadata
β βββ data.yaml # YOLO dataset configuration
β βββ train/ # 5,733 training image & label pairs
β βββ val/ # 1,228 validation image & label pairs
β βββ test/ # 1,229 test image & label pairs
βββ splits/ # Local leak-free cluster-isolated splits
βββ purity_engine/ # Integrity Engine & Vernacular Voice Package
β βββ model_client.py # Mock & TFLite INT8 model abstraction
β βββ board_profiles.json # Baseline component expectations & scrap floors
β βββ purity_assay.py # BIS calculation & dynamic pricing formula
β βββ vernacular_voice.py # 8-language voice alert generator (.opus fallback)
β βββ pcb_analyzer.py # Unified orchestrator entry point
βββ training/ # Custom YOLOv8 training pipeline
β βββ train.py # Fine-tuning & TFLite export script
β βββ train_config.yaml # Copy-paste & class-weighted loss config
βββ pipeline/ # Dataset harvesting, validation & dedup
β βββ auto_annotate.py # Zero-shot YOLO-World auto-annotation engine
β βββ crawler.py # Multi-threaded web harvester (16 threads)
β βββ validator.py # Image integrity & resolution validator
β βββ processor.py # EXIF transpose & image normalizer
β βββ dedup.py # Exact & perceptual hash deduplication
β βββ splitter.py # Cluster-aware dataset partitioner
βββ prepare_hf_dataset.py # Formats splits into huggingface_dataset/
βββ tests/ # Automated pytest test suite (20 tests)
βββ test_purity_assay.py
π Dataset Statistics & Hugging Face Hub CLI Upload
The dataset contains 8,190 clean normalized JPEGs and 6,377 fine-grained bounding boxes.
Dataset Partitioning
| Split | Images & Bounding Box Pairs | Ratio |
|---|---|---|
| Train | 5,733 images | $70%$ |
| Validation | 1,228 images | $15%$ |
| Test | 1,229 images | $15%$ |
| Total | 8,190 images | $100%$ |
π Pushing Dataset to Hugging Face via HF CLI
The dataset is pre-formatted in huggingface_dataset/ with YAML metadata. Push it directly to your Hugging Face Hub account using the Hugging Face CLI:
# 1. Login to Hugging Face
huggingface-cli login
# 2. Upload the staged huggingface_dataset directory
cd huggingface_dataset
huggingface-cli upload <your-hf-username>/<your-dataset-name> . --repo-type=dataset
π·οΈ 7 Fine-Grained Class Taxonomy
| Class ID | Class Name | Description |
|---|---|---|
0 |
cpu_socket |
LGA, PGA, or ZIF processor socket footprints |
1 |
gold_finger |
Gold-plated edge connector contacts (PCIe, RAM contacts) |
2 |
ic_chip |
Packaged ICs and BGA microchips |
3 |
tantalum_capacitor |
SMD tantalum capacitors (molded yellow/black/orange) |
4 |
forcibly_desoldered_pad |
Exposed pads with jagged solder, blowtorch marks, torn traces (fraud signal) |
5 |
factory_unpopulated_pad |
Clean silkscreen outline with smooth solder dots left empty (NOT fraud) |
6 |
occluded_region |
Footprints obscured by heatsinks, metal shielding, or heavy dust |
ποΈ Custom Model Training Pipeline
Fine-tune YOLOv8 on the dataset using Copy-Paste synthetic augmentation (copy_paste: 0.8) and elevated class loss gain (cls: 2.5):
# Run training using project virtual environment
.venv/bin/python training/train.py --epochs 50 --imgsz 960 --batch 8
Dynamic Scrap Grade Price Formula
- Server / GPU PCBs: $\text{Floor} = 15%$
- Desktop PCBs: $\text{Floor} = 30%$
- Low-Grade Power PCBs: $\text{Floor} = 60%$
π‘οΈ Running Integrity Assay Engine (purity_engine)
from purity_engine import PCBAnalyzer
analyzer = PCBAnalyzer()
# 2-Photo Workflow (Front + Back PCB Photos)
result = analyzer.analyze_board(
front_image="front_top_down.jpg",
back_image="back_bottom_down.jpg",
base_price=100.0,
form_factor="desktop_atx",
lang="hi", # Hindi voice alert
)
print(f"Board Integrity Score: {result['board_integrity_score']}%")
print(f"Adjusted Purchase Price: βΉ{result['adjusted_price']}")
print(f"Voice Alert: {result['voice_alert']['transcript']}")
π§ͺ Running Automated Unit Tests
.venv/bin/python -m pytest tests/test_purity_assay.py tests/test_pipeline.py
(All 20 unit tests passing)
- Downloads last month
- 149