Skip to content

eyildiz-ugoe/wire_detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”Œ Efficient-UNet Wire Detection for Automated Disassembly

This repository provides a standalone implementation of wire detection using an EfficientNetB7-based U-Net architecture for automated disassembly processes in robotics applications.

Key Features:

  • 🎯 EfficientNetB7 Backbone: State-of-the-art encoder for wire segmentation
  • πŸ”¬ U-Net Architecture: Precise pixel-level wire localization
  • πŸ“Š High Accuracy: Robust wire detection in complex scenes
  • πŸš€ Modern TensorFlow 2.x: Compatible with latest frameworks
  • 🐍 Pure Python: Standalone usage without ROS dependency

🎬 Demo

Input Image Detected Wires
Input Output

Inference Pipeline

Inference Pipeline

The detection pipeline processes RGB images through the EfficientNetB7-UNet to produce wire segmentation masks.

Training Pipeline

Training Pipeline

Model Performance

Model Metrics

Performance comparison of different backbone architectures on wire detection task.


οΏ½ Methodology

This wire detection module is designed for setups where a monocular camera faces the device's surface perpendicularly. The system consists of two main components:

Data Generation (Datagen) Block

The data generation pipeline addresses the challenge of limited annotated training data by implementing aggressive augmentation strategies. Starting from a small set of user-annotated raw images, the system generates a massive number of augmented images along with their corresponding annotations. This approach enables the deep neural network to learn robust wire detection features despite the initial data scarcity.

Model Block

The detection model processes RGB images from the monocular camera to identify learned wire features and generate pixel-level segmentation maps. The architecture employs EfficientNetB7 as the encoder backbone within a U-Net framework, leveraging pre-trained ImageNet weights for effective transfer learning.

Training Pipeline

The training pipeline showing data augmentation and model architecture. The EfficientNetB7 encoder is trained on massively augmented data to achieve robust wire segmentation.

Key Technical Aspects:

  • Camera Setup: Monocular camera with perpendicular view to device surface
  • Data Augmentation: Extensive augmentation from limited annotated samples
  • Architecture: EfficientNetB7-UNet for semantic segmentation
  • Training Strategy: Transfer learning with ImageNet pre-trained weights
  • Output: Pixel-level binary segmentation masks for wire detection

πŸ“Š Dataset & Evaluation

Dataset

The wire detection system was developed and validated using a specialized dataset focused on digital entertainment devices:

  • Domain: Wire detection in disassembled DVD players, gaming consoles, and similar devices
  • Raw Images: 100 top-down images collected from online sources
  • Manual Annotation: All visible wires hand-annotated for ground truth
  • Augmented Dataset: ~20,000 augmented images generated for robust training
  • Augmentation Ratio: 200Γ— expansion from original dataset

πŸ“¦ WireDTF Dataset: The training data is available as TensorFlow Records on Zenodo:

  • Dataset Name: WireDTF (Wire Detection TensorFlow Records)
  • Download: WireDTF on Zenodo
  • Format: TensorFlow Records (.tfrecord)
  • Purpose: Direct loading for DCNN training

This aggressive augmentation strategy addresses the challenge of limited annotated data while ensuring the model learns invariant wire features across various conditions.

Evaluation Metrics

The model performance is assessed using two complementary metrics:

1. IoU (Intersection over Union) / F1 Score

Standard metric for pixel-wise segmentation accuracy. Measures the overlap between predicted and ground truth segmentation:

IoU = (Prediction ∩ Ground Truth) / (Prediction βˆͺ Ground Truth)

2. SSIM (Structural Similarity Index)

Perceptual metric that evaluates image quality based on luminance, contrast, and structural information. SSIM provides insight into how well the predicted segmentation preserves the structural characteristics of wire patterns.

Model Comparison Results

Model Performance Comparison

Comprehensive evaluation of state-of-the-art encoder architectures:

Model SSIM (Max/Mean/Min) IoU (Max/Mean/Min)
EfficientNetB7 ⭐ 0.956 / 0.877 / 0.761 0.988 / 0.952 / 0.897
InceptionV3 0.944 / 0.863 / 0.758 0.977 / 0.947 / 0.894
InceptionResNetV2 0.941 / 0.859 / 0.743 0.983 / 0.943 / 0.886
DenseNet201 0.940 / 0.862 / 0.747 0.978 / 0.945 / 0.891

Key Findings:

  • EfficientNetB7 achieves the highest scores in both SSIM and IoU metrics
  • Superior performance in low-resolution and low-feature conditions
  • Demonstrates robust feature extraction capabilities for wire detection
  • Mean IoU of 0.952 indicates excellent segmentation accuracy
  • High SSIM scores confirm structural similarity preservation

πŸ“‹ Table of Contents


⚑ Quick Start

git clone https://github.com/eyildiz-ugoe/wire_detection.git
cd wire_detection
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt

# Run detection on sample image
python scripts/standalone_detection.py \
  --image assets/input.png \
  --weights models/efficientnetb7_unet.h5 \
  --output-dir results/

πŸ”§ Installation

1. Clone & Setup Environment

git clone https://github.com/eyildiz-ugoe/wire_detection.git
cd wire_detection
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Requirements: Python 3.8+, TensorFlow 2.15+, OpenCV, NumPy, scikit-image, PyYAML

2. Download Model Weights


🎯 Usage

Command-Line Interface

# Basic usage
python scripts/standalone_detection.py \
  --image path/to/image.png \
  --weights models/efficientnetb7_unet.h5 \
  --output-dir results/

# Using environment variable
export WIRE_DETECTION_WEIGHTS=models/efficientnetb7_unet.h5
python scripts/standalone_detection.py --image input.png --output-dir results/

Python API

from src.wire_detection import load_wire_model, get_prediction, get_wire_pixel

# Load model and run detection
model = load_wire_model('models/efficientnetb7_unet.h5')
pred, contours, mask_paths, overlay_path = get_prediction('input.png', 'output/', model)
wire_pixels = get_wire_pixel(contours)

print(f"Detected {len(contours)} wire segment(s)")

πŸ—‚οΈ Project Structure

wire_detection/
β”œβ”€β”€ src/                    # Core library
β”‚   └── wire_detection.py
β”œβ”€β”€ scripts/                # CLI tools
β”‚   └── standalone_detection.py
β”œβ”€β”€ tests/                  # Unit tests (6 tests)
β”‚   └── test_wire_detection.py
β”œβ”€β”€ assets/                 # Example images
β”‚   β”œβ”€β”€ input.png
β”‚   └── output.png
└── models/                 # Pre-trained weights
    └── efficientnetb7_unet.h5

πŸ—οΈ Model Architecture

Efficient-UNet:

  • Encoder: EfficientNetB7 (pre-trained on ImageNet)
  • Decoder: U-Net upsampling path
  • Input: 256Γ—256Γ—3 RGB images
  • Output: Binary segmentation mask (256Γ—256)
  • Parameters: ~66M trainable parameters
  • Framework: TensorFlow 2.x / Keras

πŸ“Š Output Format

  1. Wire Overlay (wire_map.png): RGB visualization with detected wires in red
  2. Segment Masks (part_mask_segment*.png): Individual binary masks
  3. Metadata (wire_detection_data.json): Contour coordinates and bounding boxes

πŸ§ͺ Testing

python -m pytest tests/ -v
# All 6 tests should pass βœ…

πŸ“š Citation

This work is part of the visual intelligence system for automated disassembly.

πŸ“– Read the Paper: An Extended Visual Intelligence Scheme for Disassembly in Automated Recycling Routines

Published in Communications in Computer and Information Science, November 2022

If helpful in your research, please cite:

@inproceedings{yildiz2022extended,
  title={An Extended Visual Intelligence Scheme for Disassembly in Automated Recycling Routines},
  author={Yildiz, Erenus and Renaudo, Erwan and Hollenstein, Jakob and Piater, Justus and W{\"o}rg{\"o}tter, Florentin},
  booktitle={Robotics, Computer Vision and Intelligent Systems},
  series={Communications in Computer and Information Science},
  year={2022},
  publisher={Springer},
  doi={10.1007/978-3-031-19650-8_2}
}

Authors: Erenus Yildiz, Erwan Renaudo, Jakob Hollenstein, Justus Piater, Florentin WΓΆrgΓΆtter


πŸ”§ Troubleshooting

ModuleNotFoundError: Run from repository root or set PYTHONPATH

export PYTHONPATH="${PYTHONPATH}:$(pwd)"

TensorFlow GPU errors: Use CPU mode

CUDA_VISIBLE_DEVICES="" python scripts/standalone_detection.py ...

πŸ“ž Contact


πŸŽ‰ What's New

βœ… Pure Python (no ROS dependency)
βœ… TensorFlow 2.x support
βœ… Command-line interface
βœ… Clean API & comprehensive docs
βœ… Unit tests & example assets


About

Publicized code for the standalone implementation of wire detection using an EfficientNetB7-based U-Net architecture for automated disassembly processes in robotics applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages