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.
- 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
- Python 3.8 or higher
- pip package manager
# 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.shManual 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# 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.jpgExample 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)
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/ScrewCTFExample 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.
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 |
The ScrewCTF (Screw Classification TensorFlow) dataset contains 24,000+ labeled images of screw heads.
| 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 |
Zenodo: https://zenodo.org/records/4727709
wget https://zenodo.org/records/4727709/files/ScrewCTF.rar?download=1 -O ScrewCTF.rar
unrar x ScrewCTF.rarDataset 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)
βββ ...
- 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
| 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 |
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
This work was presented at ROBOVIS 2020 (International Conference on Robotics, Computer Vision and Intelligent Systems) in Budapest, Hungary.
- 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
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.
@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}
}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
1. Model weights not found
# Download using gdown
pip install gdown
gdown 1YKjILO6Ts_uvkAp0uIRPTBg_Mroyvt2j -O weights/screw_model.h52. 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 numpy4. OpenCV not available (optional)
The visualization uses OpenCV if available, but falls back to PIL automatically:
pip install opencv-python # Optional, for better visualization5. 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
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- π Paper: DOI: 10.5220/0009979900610068
- π Dataset: Zenodo - ScrewCTF
- π§ Model Weights: Google Drive
- ποΈ Conference: ROBOVIS 2020
- π¬ Lab: Florentin WΓΆrgΓΆtter's Lab, University of GΓΆttingen
- Erenus Yildiz - Lead Developer & Researcher - GitHub
- Florentin WΓΆrgΓΆtter - Principal Investigator
--
If you use this work in your research, please cite our paper!



