Downloads · 30 days
0
Asadrizvi64/electrical-outlets-diagnostic
electrical-outlets-diagnostic is a image classification model from Asadrizvi64. Use it when you need a label for an image. The card lists the license as mit.
Non-intrusive AI diagnostic system for electrical outlets and switches using image classification and audio analysis with decision-level fusion.
Downloads · 30 days
0
Access
Public
Updated Feb 23, 2026
Repo size
19.4 MB
Likes
0
Public
Click a slice to open those files.
.pt19.4 MB · 99%
From the Hugging Face model README
Non-intrusive AI diagnostic system for electrical outlets and switches using image classification and audio analysis with decision-level fusion.
This pipeline analyzes photos and/or audio recordings of electrical outlets to detect potential safety issues without requiring physical inspection. It uses two independent models fused at the decision level for robust predictions.
config/thresholds.yamlCV/
├── config/
│ ├── label_mapping.json # Class definitions & folder→class mapping
│ ├── image_train_config.yaml # Image training hyperparameters
│ ├── audio_train_config.yaml # Audio training hyperparameters
│ ├── thresholds.yaml # Fusion confidence thresholds
│ └── schema.yaml # API output schema
├── src/
│ ├── data/
│ │ ├── image_dataset.py # Image dataset with stratified splits
│ │ └── audio_dataset.py # Audio dataset with stratified splits
│ ├── models/
│ │ ├── image_model.py # EfficientNet-B0 + MLP classifier
│ │ └── audio_model.py # Spectrogram CNN classifier
│ ├── fusion/
│ │ └── fusion_logic.py # Decision-level fusion
│ └── inference/
│ └── wrapper.py # End-to-end inference pipeline
├── training/
│ ├── train_image.py # Image model training (2-stage)
│ └── train_audio.py # Audio model training
├── api/
│ └── main.py # FastAPI endpoint
├── weights/
│ ├── electrical_outlets_image_best.pt # Trained image model
│ └── electrical_outlets_audio_best.pt # Trained audio model
├── tests/
│ └── test_fusion.py # Fusion logic tests
├── test_single_image.py # Quick single-image testing
├── requirements.txt
└── README.md
git clone https://huggingface.co/<your-repo>/electrical-outlets-diagnostic
cd electrical-outlets-diagnostic
pip install -r requirements.txt
# If GPU: install CUDA-enabled PyTorch
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
# Also needed on Windows:
pip install soundfile
Download the model weights from the HuggingFace repository and place them in weights/:
weights/
├── electrical_outlets_image_best.pt (~ 17 MB)
└── electrical_outlets_audio_best.pt (~ 2 MB)
python test_single_image.py --image path/to/outlet_photo.jpg
Output:
==================================================
burned_outlet.jpg
==================================================
→ burn_overheating (high severity)
→ 87.3% confidence
→ issue_detected
burn_overheating 87.3% ██████████████████████████ ◄
cracked_faceplate 5.2% █
loose_outlet 3.1% ▊
normal 2.8% ▊
water_exposed 1.6% ▍
uvicorn api.main:app --host 0.0.0.0 --port 8000
POST /v1/diagnose/electrical_outlets
Upload image and/or audio for diagnosis:
# Image only
curl -X POST http://localhost:8000/v1/diagnose/electrical_outlets \
-F "image=@outlet_photo.jpg"
# Image + Audio
curl -X POST http://localhost:8000/v1/diagnose/electrical_outlets \
-F "image=@outlet_photo.jpg" \
-F "audio=@outlet_recording.wav"
Response:
{
"diagnostic_element": "electrical_outlets",
"result": "issue_detected",
"issue_type": "burn_overheating",
"severity": "high",
"confidence": 0.873,
"modality_contributions": null,
"primary_issue": "burn_overheating",
"secondary_issue": null
}
GET /health — Check model availability
from src.inference.wrapper import run_electrical_outlets_inference
result = run_electrical_outlets_inference(
image_path="path/to/photo.jpg",
audio_path="path/to/recording.wav", # optional
)
print(result)
python training/train_image.py --device cuda
Two-stage training:
python training/train_audio.py --device cuda
Single-stage with SpecAugment, class-weighted loss, cosine LR schedule.
| Class | Issue Type | Severity | Source Folders |
|---|---|---|---|
| 0 | burn_overheating | high | Burn marks (250), Discoloration (100), Sparking damage (150) |
| 1 | cracked_faceplate | medium | Cracked faceplate (150), Damaged switches (50) |
| 2 | loose_outlet | medium | Loose outlet (200), Exposed wiring (150) |
| 3 | normal | low | Normal outlets (50), Normal switches (50) |
| 4 | water_exposed | high | Water intrusion (150) |
| Class | Issue Type | Severity |
|---|---|---|
| 0 | normal | low |
| 1 | buzzing | high |
| 2 | crackling_arcing | high |
| 3 | arcing_pop | critical |
| Level | Action Required |
|---|---|
| low | Monitor — no immediate action |
| medium | Schedule repair |
| high | Shut off circuit immediately |
| critical | Shut off main breaker immediately |
The fusion layer combines image and audio predictions:
issue_detected with max severitynormaluncertain (unless one has >92% confidence)uncertain over normal when confidence is lowDataset: 1,299 images
Validation Split: 194 images
Best Epoch: 76
| Metric | Value |
|---|---|
| Accuracy | 77.3% |
| Minimum Per-Class Recall | 66.7% |
| Macro Recall | 77.0% |
| Trainable Parameters | 658,437 (14.1%) |
| Class | Recall | Notes |
|---|---|---|
| burn_overheating | 68% | Confused with dark loose_outlet cases |
| cracked_faceplate | 63% | Lowest data (200 images) |
| loose_outlet | 98% | Strong visual pattern |
| normal | 93% | Despite only 100 images |
| water_exposed | 64% | Subtle cues, limited data |
Dataset: 100 WAV files
Validation Recall: 100% macro recall
Converged: Epoch 15
⚠ Audio validation dataset is small and partially synthetic; real-world generalization may differ.
| Version | Min Recall | Accuracy | Key Change |
|---|---|---|---|
| V1 | 31.8% | 47% | Baseline |
| V2 | 26.7% | 44% | High LR → overfitting |
| V3 | 27.2% | 52% | Frozen backbone |
| V4 | 0% | — | Folder mapping bug |
| V5 | 63.6% | 77.3% | Fixed dataset loading |
| V5.1 | 66.7% | 77.3% | Larger head + improved LR |
Total improvement:
+35 pts minimum recall
+30 pts accuracy
Recommended use: screening / preliminary diagnostics only
Proprietary — for use in the Electrical Outlets diagnostic pipeline only.