Update README.md
#2
by
henrysalim - opened
README.md
CHANGED
|
@@ -1,138 +1,17 @@
|
|
| 1 |
-
# Real‑Life Industrial Dataset of Casting Product
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
##
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
* **Total images**:
|
| 12 |
-
|
| 13 |
-
* \~6,633 training images
|
| 14 |
-
* \~715 test images ([Medium][4], [Medium][2])
|
| 15 |
-
* **Image size**: 300×300 px (some sources mention 512×512) grayscale ([Medium][4])
|
| 16 |
-
* **Classes (binary)**:
|
| 17 |
-
|
| 18 |
-
* `ok_front` (non-defective)
|
| 19 |
-
* `def_front` (defective)
|
| 20 |
-
|
| 21 |
-
---
|
| 22 |
-
|
| 23 |
-
## 📁 Directory Structure
|
| 24 |
-
|
| 25 |
-
```
|
| 26 |
-
casting_data/
|
| 27 |
-
├── train/
|
| 28 |
-
│ ├── ok_front/ # Non-defective images (~2,875)
|
| 29 |
-
│ └── def_front/ # Defective images (~3,758)
|
| 30 |
-
└── test/
|
| 31 |
-
├── ok_front/ # Non-defective (~262)
|
| 32 |
-
└── def_front/ # Defective (~453)
|
| 33 |
-
```
|
| 34 |
-
|
| 35 |
-
---
|
| 36 |
-
|
| 37 |
-
## 🎯 Use Cases
|
| 38 |
-
|
| 39 |
-
* **Automated visual quality inspection** in manufacturing
|
| 40 |
-
* Binary classification (defective vs. non‑defective)
|
| 41 |
-
* Convolutional Neural Network (CNN) model training & evaluation
|
| 42 |
-
* Transfer learning or fine-tuning on use-specific defects
|
| 43 |
-
|
| 44 |
-
---
|
| 45 |
-
|
| 46 |
-
## 🧪 Example Model Performance
|
| 47 |
-
|
| 48 |
-
* CNNs reach up to **99%+ accuracy** in defect classification ([Labellerr][1], [Medium][2], [Google Sites][5])
|
| 49 |
-
* Logistic regression on raw images performs much worse (\~73% accuracy) ([Google Sites][5])
|
| 50 |
-
|
| 51 |
-
These results show deep learning is well-suited for this kind of QC task.
|
| 52 |
-
|
| 53 |
-
---
|
| 54 |
-
|
| 55 |
-
## 🛠️ Setup & Usage
|
| 56 |
-
|
| 57 |
-
### 1. Install dependencies
|
| 58 |
-
|
| 59 |
-
```bash
|
| 60 |
-
pip install tensorflow keras numpy matplotlib
|
| 61 |
-
```
|
| 62 |
-
|
| 63 |
-
### 2. Prepare data
|
| 64 |
-
|
| 65 |
-
Download and extract the dataset into your working directory:
|
| 66 |
-
|
| 67 |
-
```
|
| 68 |
-
casting_data/
|
| 69 |
-
├── train/
|
| 70 |
-
│ └── ...
|
| 71 |
-
└── test/
|
| 72 |
-
└── ...
|
| 73 |
-
```
|
| 74 |
-
|
| 75 |
-
### 3. Load data with `ImageDataGenerator`
|
| 76 |
-
|
| 77 |
-
Example for training and testing pipelines:
|
| 78 |
-
|
| 79 |
-
```python
|
| 80 |
-
from tensorflow.keras.preprocessing.image import ImageDataGenerator
|
| 81 |
-
|
| 82 |
-
# Training generator
|
| 83 |
-
train_gen = ImageDataGenerator(rescale=1./255).flow_from_directory(
|
| 84 |
-
'casting_data/train',
|
| 85 |
-
target_size=(300,300),
|
| 86 |
-
color_mode='grayscale',
|
| 87 |
-
class_mode='binary',
|
| 88 |
-
batch_size=32
|
| 89 |
-
)
|
| 90 |
-
|
| 91 |
-
# Testing generator
|
| 92 |
-
test_gen = ImageDataGenerator(rescale=1./255).flow_from_directory(
|
| 93 |
-
'casting_data/test',
|
| 94 |
-
target_size=(300,300),
|
| 95 |
-
color_mode='grayscale',
|
| 96 |
-
class_mode='binary',
|
| 97 |
-
batch_size=32,
|
| 98 |
-
shuffle=False
|
| 99 |
-
)
|
| 100 |
-
```
|
| 101 |
-
|
| 102 |
-
### 4. Define & Train CNN
|
| 103 |
-
|
| 104 |
-
Simple Keras example:
|
| 105 |
-
|
| 106 |
-
```python
|
| 107 |
-
from tensorflow.keras import models, layers
|
| 108 |
-
|
| 109 |
-
model = models.Sequential([
|
| 110 |
-
layers.Conv2D(32, (3,3), activation="relu", input_shape=(300,300,1)),
|
| 111 |
-
layers.MaxPooling2D(2),
|
| 112 |
-
layers.Conv2D(64, (3,3), activation="relu"),
|
| 113 |
-
layers.MaxPooling2D(2),
|
| 114 |
-
layers.Flatten(),
|
| 115 |
-
layers.Dense(128, activation="relu"),
|
| 116 |
-
layers.Dense(1, activation="sigmoid")
|
| 117 |
-
])
|
| 118 |
-
|
| 119 |
-
model.compile(loss="binary_crossentropy", optimizer="adam",
|
| 120 |
-
metrics=["accuracy"])
|
| 121 |
-
|
| 122 |
-
model.fit(train_gen, epochs=10, validation_data=test_gen)
|
| 123 |
-
```
|
| 124 |
-
|
| 125 |
-
### 5. Evaluate & Predict
|
| 126 |
-
|
| 127 |
-
```python
|
| 128 |
-
loss, acc = model.evaluate(test_gen)
|
| 129 |
-
print(f"Test accuracy: {acc:.2%}")
|
| 130 |
-
```
|
| 131 |
-
|
| 132 |
-
---
|
| 133 |
-
|
| 134 |
-
## 🔍 References & Further Reading
|
| 135 |
-
|
| 136 |
-
* Medium guide on casting defect classification and CNN performance ([Medium][4], [Labellerr][1], [Analytics Journal][6])
|
| 137 |
-
* Analytics Vidhya case study splitting \~3,758 defective and \~2,875 non‑defective images in training, and \~453/262 in test sets; all grayscale with size 300×300 px ([Medium][4])
|
| 138 |
-
* Labellerr blog on automated casting inspection with CNNs (7,300 images, similar structure) ([Labellerr][1])
|
|
|
|
| 1 |
+
# Real‑Life Industrial Dataset of Casting Product
|
| 2 |
|
| 3 |
+
Disesuaikan kembali oleh tim 200 OK untuk keperluan membuat model prediksi menggunakan Xception untuk mendeteksi cacat pada _impeller submersible pump_.
|
| 4 |
|
| 5 |
+
## Tentang Dataset
|
| 6 |
+
Dimensi: 512 x 512 px _grayscale_<br>
|
| 7 |
+
Dataset ini tanpa augmentasi lebih lanjut<br>
|
| 8 |
+
Total gambar: 1300 gambar<br>
|
| 9 |
+
* 519 gambar berlabel ok_front
|
| 10 |
+
* 781 gambar berlabel def_front
|
| 11 |
|
| 12 |
+
## Penggunaan Dataset
|
| 13 |
+
Untuk _training_: 1040 gambar<br>
|
| 14 |
+
Untuk _validation_: 260 gambar<br>
|
| 15 |
|
| 16 |
+
## Sumber Dataset
|
| 17 |
+
Klik tautan [ini](https://www.kaggle.com/datasets/ravirajsinh45/real-life-industrial-dataset-of-casting-product) untuk melihat _dataset_ asli.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|