Skip to content

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

License

Notifications You must be signed in to change notification settings

eyildiz-ugoe/screw_classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

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

Repository files navigation

πŸ”© DCNN-based Screw Classification in Automated Disassembly Processes

Screw Types

Conference DOI Dataset Python TensorFlow

πŸ“– Overview

E-waste recycling is thriving yet there are many challenges waiting to be addressed until high-degree, device-independent automation is possible. One of these challenges is to have automated procedures for screw classification.

This repository implements a universal, generalizable, and extendable screw classifier for automated disassembly routines. Our classifier combines a Hough transform with state-of-the-art deep convolutional neural networks, achieving 97% accuracy while maintaining high computational speed.

Architecture

πŸ† Key Features

  • 97% classification accuracy on 12 screw types
  • EfficientNetB2-based architecture (335 layers)
  • Real-time visualization with confidence scores
  • Batch evaluation to reproduce paper results
  • Production-ready single-file implementation
  • Publicly available dataset (ScrewCTF) with 24,000+ images

πŸš€ Quick Start

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Installation

# 1. Clone the repository
git clone https://github.com/eyildiz-ugoe/screw-classification.git
cd screw-classification

# 2. Run automated setup
chmod +x scripts/setup.sh
./scripts/setup.sh

Manual Setup:

# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate

# Install dependencies
pip install tensorflow pillow numpy

# Download model weights
pip install gdown
mkdir -p weights
gdown 1YKjILO6Ts_uvkAp0uIRPTBg_Mroyvt2j -O weights/screw_model.h5

# (Optional) Download dataset for evaluation
wget https://zenodo.org/records/4727709/files/ScrewCTF.rar?download=1 -O ScrewCTF.rar
unrar x ScrewCTF.rar

🎯 Usage

Single Image Classification

# Activate virtual environment
source .venv/bin/activate

# Classify image with interactive visualization
python scripts/classify.py path/to/screw_image.jpg

# Save visualization to file
python scripts/classify.py screw.jpg --save result.jpg

Example Output:

============================================================
🎯 Classification Results:
============================================================
1. ph1              99.6% β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
2. torx9             0.3% 
3. allen4            0.0% 
4. torx8             0.0% 
5. allen2.5          0.0% 
============================================================
βœ… Top prediction: ph1 (99.6% confidence)
============================================================

πŸ‘οΈ  Visualization window opened. Press 'q' or 'ESC' to close...

The visualization window displays:

  • Original screw image
  • Top 5 predictions with color-coded confidence bars
  • Interactive display (press 'q' or 'ESC' to close)

Batch Evaluation

Reproduce the paper's 97% accuracy on the test dataset:

# Evaluate on entire test set
python scripts/evaluate.py

# Use custom dataset path
python scripts/evaluate.py --dataset-path /path/to/ScrewCTF

Example Output:

======================================================================
πŸ“Š EVALUATION RESULTS
======================================================================

🎯 Overall Accuracy: 97.00%
   Correct: 5820/6000

πŸ“‹ Per-Class Accuracy:
----------------------------------------------------------------------
Class ID   Class Name      Accuracy    Correct/Total
----------------------------------------------------------------------
0          ph1              99.60%      498/500
1          slotted6.5      100.00%      500/500
2          torx7            99.80%      499/500
...
----------------------------------------------------------------------
Average                      97.00%
======================================================================

Results are saved to evaluation_results.json.


πŸ”§ Supported Screw Types

The classifier recognizes 12 different screw head types:

Class Type Description
0 ph1 Phillips #1
1 slotted6.5 Slotted 6.5mm
2 torx7 Torx T7
3 allen2.75 Allen/Hex 2.75mm
4 ph2 Phillips #2
5 allen4 Allen/Hex 4mm
6 torx8 Torx T8
7 slotted4.5 Slotted 4.5mm
8 torx9 Torx T9
9 torx6 Torx T6
10 slotted10 Slotted 10mm
11 allen2.5 Allen/Hex 2.5mm

πŸ“Š Dataset: ScrewCTF

The ScrewCTF (Screw Classification TensorFlow) dataset contains 24,000+ labeled images of screw heads.

Dataset Statistics

Split Total Images Images per Class Purpose
Train ~14,400 ~1,200 Model training
Test ~6,000 ~500 Performance evaluation
Eval ~3,600 ~300 Validation

Download

Zenodo: https://zenodo.org/records/4727709

wget https://zenodo.org/records/4727709/files/ScrewCTF.rar?download=1 -O ScrewCTF.rar
unrar x ScrewCTF.rar

Dataset Structure:

ScrewCTF/
β”œβ”€β”€ Train/
β”‚   β”œβ”€β”€ label_0/ (~1,200 images of ph1)
β”‚   β”œβ”€β”€ label_1/ (~1,200 images of slotted6.5)
β”‚   └── ...
β”œβ”€β”€ Test/
β”‚   β”œβ”€β”€ label_0/ (~500 images)
β”‚   └── ...
└── Eval/
    β”œβ”€β”€ label_0/ (~300 images)
    └── ...

πŸ—οΈ Architecture

Confusion Matrix

Model Details

  • Backbone: EfficientNetB2 (335 layers)
  • Input: 256Γ—256 RGB images
  • Preprocessing: Hough transform for edge detection
  • Output: 12-class softmax classification
  • Optimizer: Adam with categorical cross-entropy loss
  • Custom Layer: FixedDropout for regularization

Performance Metrics

Metric Value
Overall Accuracy 97.0%
Average Precision 96.8%
Average Recall 96.5%
F1-Score 96.6%
Inference Time ~50ms per image (CPU)
Model Size 91 MB

πŸ“ Repository Structure

screw-classification/
β”œβ”€β”€ README.md                  # This file
β”œβ”€β”€ LICENSE                    # MIT License
β”œβ”€β”€ requirements.txt           # Python dependencies
β”œβ”€β”€ .gitignore                # Git ignore rules
β”‚
β”œβ”€β”€ scripts/                   # All executable scripts
β”‚   β”œβ”€β”€ classify.py           # Single-image classifier
β”‚   β”œβ”€β”€ evaluate.py           # Batch evaluation
β”‚   β”œβ”€β”€ tfreader.py           # TFRecord dataset reader
β”‚   └── setup.sh              # Automated setup
β”‚
β”œβ”€β”€ weights/                   # Model weights
β”‚   └── screw_model.h5        # Pre-trained EfficientNetB2
β”‚
└── assets/                    # Documentation images
    β”œβ”€β”€ types.jpg             # Screw type overview
    β”œβ”€β”€ confusion_matrix.jpg  # Model performance
    β”œβ”€β”€ head_architecture.jpg # Architecture diagram
    └── hddoutput.jpg         # Real-world example

πŸ”¬ Research & Citation

This work was presented at ROBOVIS 2020 (International Conference on Robotics, Computer Vision and Intelligent Systems) in Budapest, Hungary.

Publication Details

  • Title: DCNN-based Screw Classification in Automated Disassembly Processes
  • Authors: Erenus Yildiz, Florentin WΓΆrgΓΆtter
  • Conference: ROBOVIS 2020
  • Date: November 2020
  • DOI: 10.5220/0009979900610068
  • Lab: Florentin WΓΆrgΓΆtter's Lab

Abstract

E-waste recycling is thriving yet there are many challenges waiting to be addressed until high-degree, device-independent automation is possible. One of these challenges is to have automated procedures for screw classification. Here we specifically address the problem of classification of the screw heads and implement a universal, generalizable, and extendable screw classifier which can be deployed in automated disassembly routines. We selected the best performing state-of-the-art classifiers and compared their performance to that of our architecture, which combines a Hough transform with the top-performing state-of-the-art deep convolutional neural network proven by our experiments. We show that our classifier outperforms currently existing methods by achieving 97% accuracy while maintaining a high speed of computation. Data set and code of this study are made public.

BibTeX Citation

@inproceedings{yildiz2020dcnn,
  title={DCNN-based Screw Classification in Automated Disassembly Processes},
  author={Yildiz, Erenus and W{{\"o}}rg{{\"o}}tter, Florentin},
  booktitle={Proceedings of the 5th International Conference on Robotics, Computer Vision and Intelligent Systems (ROBOVIS 2020)},
  pages={61--68},
  year={2020},
  organization={SCITEPRESS},
  doi={10.5220/0009979900610068},
  address={Budapest, Hungary}
}

πŸ“Έ Real-World Applications

HDD Disassembly

Example of screw classification in automated HDD disassembly processes

The classifier has been successfully deployed in:

  • Automated hard disk drive (HDD) disassembly
  • Electronic waste recycling systems
  • Robotic disassembly workflows

πŸ› Troubleshooting

Common Issues

1. Model weights not found

# Download using gdown
pip install gdown
gdown 1YKjILO6Ts_uvkAp0uIRPTBg_Mroyvt2j -O weights/screw_model.h5

2. GPU/CUDA errors
The code runs on CPU by default to avoid compatibility issues. GPU support can be enabled by removing this line from the scripts:

os.environ['CUDA_VISIBLE_DEVICES'] = '-1'

3. Import errors

# Ensure virtual environment is activated
source .venv/bin/activate
pip install --upgrade tensorflow pillow numpy

4. OpenCV not available (optional)
The visualization uses OpenCV if available, but falls back to PIL automatically:

pip install opencv-python  # Optional, for better visualization

5. Low accuracy on custom images

  • Ensure images show clear, centered screw heads
  • Check image quality and lighting conditions
  • Images should be similar to the training data conditions
  • The model expects well-lit, focused close-ups of screw heads

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ”— Links & Resources


πŸ‘₯ Authors

  • Erenus Yildiz - Lead Developer & Researcher - GitHub
  • Florentin WΓΆrgΓΆtter - Principal Investigator

--

If you use this work in your research, please cite our paper!

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

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published