Datasets:
Please enter the commit message for your changes. Lines starting
Browse fileswith '#' will be ignored, and an empty message aborts the commit.
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
new file: README.md
new file: count_pcb_images.py
- README.md +113 -0
- count_pcb_images.py +62 -0
README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pretty_name: Innodisk PCB Image Dataset
|
| 3 |
+
license: cc-by-nc-4.0
|
| 4 |
+
tags:
|
| 5 |
+
- image-classification
|
| 6 |
+
- pcb
|
| 7 |
+
- defect-detection
|
| 8 |
+
- innodisk
|
| 9 |
+
- small-sample-learning
|
| 10 |
+
configs:
|
| 11 |
+
- name: default
|
| 12 |
+
data_files:
|
| 13 |
+
train:
|
| 14 |
+
- "train_20_20/*.jpg"
|
| 15 |
+
- "train_20_20_R/*.jpg"
|
| 16 |
+
- "train_40_20/*.jpg"
|
| 17 |
+
- "train_40_20_R/*.jpg"
|
| 18 |
+
- "train_60_20/*.jpg"
|
| 19 |
+
- "train_80_20/*.jpg"
|
| 20 |
+
- "train_100_20/*.jpg"
|
| 21 |
+
test:
|
| 22 |
+
- "test/*.jpg"
|
| 23 |
+
- "test_R/*.jpg"
|
| 24 |
+
- "test_canny/*.jpg"
|
| 25 |
+
- "test_R_canny/*.jpg"
|
| 26 |
+
val:
|
| 27 |
+
- "val/*.jpg"
|
| 28 |
+
- "val_R/*.jpg"
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
# 🚀🔬 Innodisk PCB Image Dataset
|
| 32 |
+
|
| 33 |
+
The **Innodisk PCB Image Dataset** is a collaboration between **Innodisk Corporation** and Tamkang University.
|
| 34 |
+
Designed for research on **printed‑circuit‑board (PCB) defect inspection** and **small‑sample learning**. 🧑🔧💡
|
| 35 |
+
|
| 36 |
+
| 📂 Split | 🖼️ Images | 📁 Source directories |
|
| 37 |
+
|----------|-----------|-----------------------|
|
| 38 |
+
| 🏋️♂️ Train | **500** | 7 `train_*` dirs |
|
| 39 |
+
| 🧪 Test | **240** | 4 `test*` dirs |
|
| 40 |
+
| 📝 Val | **30** | 2 `val*` dirs |
|
| 41 |
+
|
| 42 |
+
🎯 *Resolutions vary; the modal size is **188 × 128 px**.*
|
| 43 |
+
|
| 44 |
+
🔖 Filenames embed pseudo‑labels: **`pass`** (=acceptable) or **`ng`** (=defective).
|
| 45 |
+
|
| 46 |
+
---
|
| 47 |
+
|
| 48 |
+
## 🗂️ Folder layout
|
| 49 |
+
|
| 50 |
+
```
|
| 51 |
+
Innodisk_PCB_datasets/
|
| 52 |
+
├── train_20_20/ # 🏋️♂️
|
| 53 |
+
├── train_20_20_R/
|
| 54 |
+
├── train_40_20/
|
| 55 |
+
├── train_40_20_R/
|
| 56 |
+
├── train_60_20/
|
| 57 |
+
├── train_80_20/
|
| 58 |
+
├── train_100_20/
|
| 59 |
+
├── test/ # 🧪
|
| 60 |
+
├── test_R/
|
| 61 |
+
├── test_canny/
|
| 62 |
+
├── test_R_canny/
|
| 63 |
+
├── val/ # 📝
|
| 64 |
+
└── val_R/
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
---
|
| 68 |
+
|
| 69 |
+
## ⚡ Quick start
|
| 70 |
+
|
| 71 |
+
```python
|
| 72 |
+
from datasets import load_dataset
|
| 73 |
+
|
| 74 |
+
# 🔄 Load images
|
| 75 |
+
ds_train = load_dataset("evan6007/Innodisk_PCB_datasets", split="train")
|
| 76 |
+
|
| 77 |
+
# 🏷️ Derive labels from filenames
|
| 78 |
+
def add_label(example):
|
| 79 |
+
fname = example["image"].filename.lower()
|
| 80 |
+
example["label"] = 0 if "ng" in fname else 1 # 0 = defective, 1 = acceptable
|
| 81 |
+
return example
|
| 82 |
+
|
| 83 |
+
ds_train = ds_train.map(add_label)
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
---
|
| 87 |
+
|
| 88 |
+
## 🏭 Image sources & preprocessing
|
| 89 |
+
|
| 90 |
+
1. 📷 **AOI line cameras** – raw production images (`train_*`, `test*`, `val*`).
|
| 91 |
+
2. ✂️ **ROI versions** (`*_R`) – cropped component regions to reduce background noise.
|
| 92 |
+
3. 🖊️ **Canny edge maps** (`*_canny`) – generated with `cv2.Canny(img, 50, 150)`.
|
| 93 |
+
|
| 94 |
+
---
|
| 95 |
+
|
| 96 |
+
## 📜 License
|
| 97 |
+
|
| 98 |
+
Released under **Creative Commons Attribution‑NonCommercial 4.0** (CC BY‑NC‑4.0).
|
| 99 |
+
Commercial applications require prior approval from Innodisk Corporation.
|
| 100 |
+
|
| 101 |
+
---
|
| 102 |
+
|
| 103 |
+
## 📚 Citation
|
| 104 |
+
|
| 105 |
+
```bibtex
|
| 106 |
+
@dataset{innodisk_pcb_2025,
|
| 107 |
+
author = {Innodisk Corporation and Hsiao, Chao-Hsiang},
|
| 108 |
+
title = {Innodisk PCB Image Dataset},
|
| 109 |
+
year = {2025},
|
| 110 |
+
url = {https://huggingface.co/datasets/evan6007/Innodisk_PCB_datasets},
|
| 111 |
+
note = {CC BY-NC 4.0}
|
| 112 |
+
}
|
| 113 |
+
```
|
count_pcb_images.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
"""
|
| 3 |
+
Count images and summarize resolutions for Innodisk PCB dataset.
|
| 4 |
+
|
| 5 |
+
Usage:
|
| 6 |
+
python count_pcb_images.py /path/to/Innodisk_PCB_datasets
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import sys
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
from collections import defaultdict
|
| 12 |
+
from PIL import Image
|
| 13 |
+
|
| 14 |
+
IMAGE_EXTS = {'.jpg', '.jpeg', '.png', '.bmp', '.tif', '.tiff'}
|
| 15 |
+
|
| 16 |
+
def scan_dataset(root: Path):
|
| 17 |
+
splits = defaultdict(list) # split_name -> list[Path]
|
| 18 |
+
for p in root.glob('*'):
|
| 19 |
+
if not p.is_dir():
|
| 20 |
+
continue
|
| 21 |
+
name = p.name.lower()
|
| 22 |
+
if name.startswith('train'):
|
| 23 |
+
split = 'train'
|
| 24 |
+
elif name.startswith('test'):
|
| 25 |
+
split = 'test'
|
| 26 |
+
elif name.startswith('val'):
|
| 27 |
+
split = 'val'
|
| 28 |
+
else:
|
| 29 |
+
# unknown folder, skip
|
| 30 |
+
continue
|
| 31 |
+
for img in p.rglob('*'):
|
| 32 |
+
if img.suffix.lower() in IMAGE_EXTS:
|
| 33 |
+
splits[split].append(img)
|
| 34 |
+
return splits
|
| 35 |
+
|
| 36 |
+
def summarize(splits):
|
| 37 |
+
print("\n===== Image Counts =====")
|
| 38 |
+
for split, files in splits.items():
|
| 39 |
+
print(f"{split.capitalize():5s}: {len(files):,} images")
|
| 40 |
+
print("\n===== Resolution Stats =====")
|
| 41 |
+
for split, files in splits.items():
|
| 42 |
+
res_counter = defaultdict(int)
|
| 43 |
+
for img_path in files:
|
| 44 |
+
try:
|
| 45 |
+
with Image.open(img_path) as im:
|
| 46 |
+
res_counter[im.size] += 1
|
| 47 |
+
except Exception:
|
| 48 |
+
continue
|
| 49 |
+
print(f"\n[{split.capitalize()}]")
|
| 50 |
+
for (w, h), cnt in sorted(res_counter.items(), key=lambda x: (-x[1], x[0])):
|
| 51 |
+
print(f"{w}×{h}: {cnt:,}")
|
| 52 |
+
|
| 53 |
+
if __name__ == "__main__":
|
| 54 |
+
if len(sys.argv) != 2:
|
| 55 |
+
print("Usage: python count_pcb_images.py /path/to/Innodisk_PCB_datasets")
|
| 56 |
+
sys.exit(1)
|
| 57 |
+
root = Path(sys.argv[1])
|
| 58 |
+
if not root.exists():
|
| 59 |
+
print("Path does not exist:", root)
|
| 60 |
+
sys.exit(1)
|
| 61 |
+
splits = scan_dataset(root)
|
| 62 |
+
summarize(splits)
|