henrysalim's picture
Create README.md
f46c5c0 verified
|
raw
history blame
3.64 kB

Real‑Life Industrial Dataset of Casting Product 🏭

A real‑world industrial image dataset for detecting defects in casting products via quality inspection workflows.


📦 Dataset Overview

  • Type: Image classification, defect detection

  • Source: Casting product image dataset (submersible pump impellers), top‑view photos ⚙️ ([Labellerr][1], [Medium][2], [Kaggle][3])

  • Total images:

    • ~6,633 training images
    • ~715 test images ([Medium][4], [Medium][2])
  • Image size: 300×300 px (some sources mention 512×512) grayscale ([Medium][4])

  • Classes (binary):

    • ok_front (non-defective)
    • def_front (defective)

📁 Directory Structure

casting_data/
├── train/
│   ├── ok_front/         # Non-defective images (~2,875)
│   └── def_front/        # Defective images (~3,758)
└── test/
    ├── ok_front/         # Non-defective (~262)
    └── def_front/        # Defective (~453)

🎯 Use Cases

  • Automated visual quality inspection in manufacturing
  • Binary classification (defective vs. non‑defective)
  • Convolutional Neural Network (CNN) model training & evaluation
  • Transfer learning or fine-tuning on use-specific defects

🧪 Example Model Performance

  • CNNs reach up to 99%+ accuracy in defect classification ([Labellerr][1], [Medium][2], [Google Sites][5])
  • Logistic regression on raw images performs much worse (~73% accuracy) ([Google Sites][5])

These results show deep learning is well-suited for this kind of QC task.


🛠️ Setup & Usage

1. Install dependencies

pip install tensorflow keras numpy matplotlib

2. Prepare data

Download and extract the dataset into your working directory:

casting_data/
├── train/
│   └── ...
└── test/
    └── ...

3. Load data with ImageDataGenerator

Example for training and testing pipelines:

from tensorflow.keras.preprocessing.image import ImageDataGenerator

# Training generator
train_gen = ImageDataGenerator(rescale=1./255).flow_from_directory(
    'casting_data/train',
    target_size=(300,300),
    color_mode='grayscale',
    class_mode='binary',
    batch_size=32
)

# Testing generator
test_gen = ImageDataGenerator(rescale=1./255).flow_from_directory(
    'casting_data/test',
    target_size=(300,300),
    color_mode='grayscale',
    class_mode='binary',
    batch_size=32,
    shuffle=False
)

4. Define & Train CNN

Simple Keras example:

from tensorflow.keras import models, layers

model = models.Sequential([
  layers.Conv2D(32, (3,3), activation="relu", input_shape=(300,300,1)),
  layers.MaxPooling2D(2),
  layers.Conv2D(64, (3,3), activation="relu"),
  layers.MaxPooling2D(2),
  layers.Flatten(),
  layers.Dense(128, activation="relu"),
  layers.Dense(1, activation="sigmoid")
])

model.compile(loss="binary_crossentropy", optimizer="adam",
              metrics=["accuracy"])

model.fit(train_gen, epochs=10, validation_data=test_gen)

5. Evaluate & Predict

loss, acc = model.evaluate(test_gen)
print(f"Test accuracy: {acc:.2%}")

🔍 References & Further Reading

  • Medium guide on casting defect classification and CNN performance ([Medium][4], [Labellerr][1], [Analytics Journal][6])
  • 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])
  • Labellerr blog on automated casting inspection with CNNs (7,300 images, similar structure) ([Labellerr][1])