lugan's picture
Remove 941 empty MT_Free label files (missing == empty in YOLO); fixes Hugging Face dataset-viewer conversion (IndexError) and restores the Viewer
dfdbac5
|
Raw History Blame Contribute Delete
11.4 kB
---
license: cc-by-4.0
task_categories:
- object-detection
language:
- en
- zh
tags:
- magnetic-tile
- surface-defect
- defect-detection
- industrial-inspection
- object-detection
- pascal-voc
- yolo
- keenforge
size_categories:
- 1K<n<10K
---
# MagneticTile-corrected
[![DOI](https://img.shields.io/badge/DOI-10.57967%2Fhf%2F10659-blue)](https://doi.org/10.57967/hf/10659)
**Magnetic tile surface defect detection — cleaned and bounding-box standardized version of the Magnetic Tile Surface Defect Dataset.**
**磁瓦表面缺陷检测 —— 磁瓦表面缺陷数据集的目标检测清洗与边界框规整版。**
[English](#english) · [中文](#中文)
---
## English
### What is this?
A **cleaned and standardized object-detection version** of the **Magnetic Tile Surface Defect Dataset**
(Huang, Qiu & Yuan — *"Saliency of magnetic tile surface defects"*, [arXiv:1805.01168](https://arxiv.org/abs/1805.01168), 2018; upstream repo: [abin24/Magnetic-tile-defect-datasets](https://github.com/abin24/Magnetic-tile-defect-datasets.)).
The original benchmark provides only continuous probability grayscale saliency masks (PNG) without bounding boxes, contains high-frequency industrial camera burst-shot duplicate frames that cause benchmark evaluation data leakage, has blank defect annotations, and lacks standard dataset partitions.
This release converts the saliency masks into precise **YOLO TXT** and **Pascal VOC XML** bounding boxes, strips out redundant burst-shot duplicates, removes corrupt blank masks, provides a stratified 70/10/20 train/val/test split, and supplies ready-to-train YOLO configuration files.
> ✅ **Upstream license: Creative Commons Attribution 4.0 International (CC BY 4.0)**. This release maintains the same open license.
### Corrections vs. the official release
| # | Correction | Detail |
|---|---|---|
| 1 | **Added Bounding Boxes (YOLO + Pascal VOC)** | Upstream released **only grayscale saliency masks (0–255)** and zero bounding boxes. Adaptive Otsu thresholding and morphological closing were applied to extract tight, high-precision bounding boxes (437 BBoxes) across all 5 defect categories. |
| 2 | **Removed 22 Burst-Shot Duplicates** | Industrial cameras captured identical tiles in rapid burst intervals (e.g. `exp2_num_86854` vs `exp2_num_85846`, MAE = 1.64). **22 near-identical temporal duplicates were isolated into `_removed_duplicates/`**, preventing evaluation data leakage between splits. |
| 3 | **Removed 4 Zero-Defect Dirty Images** | In category `MT_Uneven`, 4 images were labeled as defective but had 100% black masks (0 foreground defect pixels: `exp3_num_45042`, `exp4_num_124690`, `exp4_num_352527`, `exp4_num_45057`). Removed to prevent harmful negative-supervision. |
| 4 | **Added Reproducible Stratified Split** | Partitioned images into **Train (70%) / Val (10%) / Test (20%)** using seeded stratified sampling to guarantee rare classes (such as `Fray`) are well-represented across all splits. |
| 5 | **Standard Packaging** | Added `data.yaml`, `classes.txt`, and synchronized dual-format annotations (`Annotations/` + `labels/`). |
| 6 | **Defect-free images ship without a label file** | The 941 `MT_Free` negatives keep their image and their (object-free) VOC XML, but have **no** YOLO `.txt`. In YOLO a missing label file is behaviorally identical to an empty one — both mean "no objects" — and empty files additionally break dataset indexing on Hugging Face. |
### Dataset at a glance
| Property | Value |
|---|---|
| Images (total) | **1,318** (941 defect-free normal negatives, 377 defective) |
| Classes | **5** — `Blowhole`, `Break`, `Crack`, `Fray`, `Uneven` |
| Bounding boxes | **437** |
| Formats | Pascal VOC XML · YOLO TXT |
| Split | train **920** (70%) / val **129** (10%) / test **269** (20%) |
**Boxes per class:**
`Break` 121 · `Blowhole` 113 · `Uneven` 105 · `Crack` 61 · `Fray` 37
### Structure
```
MagneticTile-corrected/
├── images/
│ ├── train/ # 920 images
│ ├── val/ # 129 images
│ └── test/ # 269 images
├── labels/
│ ├── train/ # 262 YOLO TXT files (defective images only)
│ ├── val/ # 35 YOLO TXT files
│ └── test/ # 80 YOLO TXT files
├── Annotations/ # Pascal VOC XML annotations (1,318 files)
├── JPEGImages/ # Full image collection (1,318 images)
├── classes.txt # 5 defect category names
├── data.yaml # Ultralytics YOLO configuration
├── _KeenForge_MagneticTile_compare.png # Visual inspection proof
└── README.md
```
> **Note on label files.** Only the **377 defective** images have a YOLO `.txt` (377 files total).
> The **941 defect-free `MT_Free` negatives have no label file** — a missing file and an empty file
> are equivalent in YOLO (both = "no objects"), and empty files break dataset indexing.
> `Annotations/` still contains a VOC XML for every image (negatives have zero `<object>` entries).
### Quick Start (Ultralytics YOLO)
```bash
yolo detect train data=data.yaml model=yolov8n.pt epochs=100 imgsz=640
```
### Citation
**1. The original dataset — please always cite this.**
```bibtex
@article{huang2018saliency,
title = {Saliency of magnetic tile surface defects},
author = {Huang, Yibin and Qiu, Congying and Yuan, Kui},
journal = {arXiv preprint arXiv:1805.01168},
year = {2018}
}
```
**2. This corrected release — please cite it as well.**
```bibtex
@misc{magnetictile_corrected,
author = {KeenForgeAI},
title = {MagneticTile-corrected: a cleaned and bounding-box standardized release of the Magnetic Tile Surface Defect dataset},
year = {2026},
version = {1.0},
publisher = {KeenForgeAI},
url = {https://huggingface.co/datasets/KeenForgeAI/MagneticTile-corrected},
note = {Curated by Lu Gan and Sam Li. Derived from Huang et al. (2018),
arXiv:1805.01168. CC BY 4.0 licensed.}
}
```
**3. The annotation and quality inspection tool.**
```bibtex
@software{keenforge,
author = {KeenForgeAI},
title = {KeenForge: a local-first, offline image annotation and model-training desktop tool},
year = {2026},
publisher = {KeenForgeAI},
url = {https://github.com/KeenForgeAI/KeenForge},
note = {MIT licensed. Developed by Lu Gan and Sam Li.}
}
```
### License
**CC BY 4.0** — Creative Commons Attribution 4.0 International, matching the upstream repository's terms. Please also credit the original authors.
---
## 中文
### 这是什么?
**磁瓦表面缺陷数据集(Magnetic Tile Surface Defect Dataset)**(Huang 等,*arXiv:1805.01168*,2018)的**目标检测清洗与标准化重构版**。
原始数据集仅提供连续灰度显著性掩码(Mask PNG),缺少矩形目标检测标注框(BBox);且工业相机连拍导致大量高相似度冗余帧,容易造成评估集数据泄漏;此外还存在纯黑空标脏样本以及目录结构割裂等问题。
本版本利用 **KeenForge** 质检引擎对原始数据进行去重与清洗,通过自适应分割算法提取紧密 BBox,补充 **YOLO TXT** 与 **Pascal VOC XML** 双格式标注,剔除 22 张时序连拍冗余图与 4 张纯黑空标脏图,并提供开箱即用的分层划分与训练配置文件。
> ✅ **上游许可证:CC BY 4.0**。本版沿用同一开源协议。
### 相对官方版的修正
| # | 修正项 | 说明 |
|---|---|---|
| 1 | **补充检测框(YOLO + Pascal VOC)** | 官方仅发布连续灰度掩码(0~255),无任何目标检测框。本版采用自适应分割与连通域提取,在 5 类缺陷中生成 **437 个高精度 Bounding Box 矩形框**。 |
| 2 | **剔除 22 张连拍重复图** | 工业相机在微秒级间隔抓拍了几乎相同的工件(如 `exp2_num_86854` 与 `exp2_num_85846` 平均像素差仅 1.64)。本版将 **22 张时序冗余帧隔离至 `_removed_duplicates/`**,彻底根除划分集间的数据泄漏。 |
| 3 | **删除 4 张纯黑空标脏图** | 在 `MT_Uneven` 类中发现 4 张标记为缺陷但掩码全黑(0 缺陷像素)的异常图(`exp3_num_45042`、`exp4_num_124690`、`exp4_num_352527`、`exp4_num_45057`),已全部剔除,杜绝负向误学习。 |
| 4 | **补充可复现的分层划分** | 采用随机种子按 **70% 训练 / 10% 验证 / 20% 测试** 进行分层抽样,确保稀缺类别(如 `Fray` 磨损)在验证与测试集中稳定存在。 |
| 5 | **标准化打包** | 补充 `data.yaml`、`classes.txt` 以及标准组织目录,支持主流框架直接训练。 |
| 6 | **无缺陷图不附带标签文件** | 941 张 `MT_Free` 正常底板保留图片与(无目标的)VOC XML,但**不提供** YOLO `.txt`。在 YOLO 中"缺少标签文件"与"空标签文件"完全等价(均表示无目标),而空文件还会导致 Hugging Face 数据集索引失败。 |
### 数据集概览
| 属性 | 值 |
|---|---|
| 图像总数 | **1,318**(941 张无缺陷正常底板,377 张缺陷样本) |
| 缺陷类别 | **5** —— `Blowhole`(气孔)、`Break`(断裂)、`Crack`(裂纹)、`Fray`(磨损)、`Uneven`(表面不平) |
| 标注框总数 | **437** |
| 标注格式 | Pascal VOC XML · YOLO TXT |
| 划分集 | train **920**(70%) / val **129**(10%) / test **269**(20%) |
**各类框数:**
`Break` 121 · `Blowhole` 113 · `Uneven` 105 · `Crack` 61 · `Fray` 37
### 目录结构
```
MagneticTile-corrected/
├── images/
│ ├── train/ # 920 张图片
│ ├── val/ # 129 张图片
│ └── test/ # 269 张图片
├── labels/
│ ├── train/ # 262 个 YOLO TXT 标注文件(仅缺陷图)
│ ├── val/ # 35 个 YOLO TXT 标注文件
│ └── test/ # 80 个 YOLO TXT 标注文件
├── Annotations/ # Pascal VOC XML 标注 (1,318 个文件)
├── JPEGImages/ # 完整图片集合 (1,318 张图片)
├── classes.txt # 5 个缺陷类别名称
├── data.yaml # Ultralytics YOLO 配置文件
├── _KeenForge_MagneticTile_compare.png # 清洗与框提取效果对比图
└── README.md
```
> **关于标签文件。** 仅 **377 张缺陷图** 有 YOLO `.txt` 标签(合计 377 个文件)。
> **941 张无缺陷 `MT_Free` 正常底板不附带标签文件** —— YOLO 中"缺少文件"与"空文件"等价(均表示无目标),
> 且空文件会导致数据集索引失败。`Annotations/` 仍为每张图保留 VOC XML(正常底板的 `<object>` 为空)。
### 快速开始 (Ultralytics YOLO)
```bash
yolo detect train data=data.yaml model=yolov8n.pt epochs=100 imgsz=640
```
### 引用
**1. 原始数据集(请务必引用)** —— 见上方英文部分 `huang2018saliency`。
**2. 本修正版(请一并引用)** —— 见上方英文部分 `magnetictile_corrected`。
**3. 标注与质检工具(可选)** —— 见上方英文部分 `keenforge`。
### 许可证
**CC BY 4.0** —— 与上游 Magnetic Tile 数据集开源协议一致。请同时注明原作者与本整理版本。