Industrial objective
The binary classifier distinguishes defective aluminium casting fronts from acceptable parts, framing computer vision as a first-pass manufacturing quality-control assistant.
Data Science
A CNN image-classification workflow for identifying defective industrial castings from visual inspection data.
View source repository
Why it matters
My role
The binary classifier distinguishes defective aluminium casting fronts from acceptable parts, framing computer vision as a first-pass manufacturing quality-control assistant.
Images are loaded from def_front and ok_front folders, converted to one-channel grayscale, resized to 128×128, normalized to the [0,1] range, and split into train, validation, and test datasets.
The compact Keras model uses optional random flips and rotations, repeated Conv2D and MaxPooling2D blocks, dense layers, dropout regularization, and a sigmoid output trained with Adam and binary cross-entropy.
Training curves, validation loss, held-out test loss, confusion matrix, classification report, precision, recall, and F1 assess both overall performance and class balance. Early stopping limits overfitting.
The final version reached approximately 95% validation accuracy and 96% test accuracy, with precision and recall between 0.93 and 0.96 across defective and acceptable classes.
A single-image helper applies the same grayscale, resize, and normalization pipeline, returns the predicted class and defect probability, and the trained model is saved for reuse without retraining.
Technical implementation
Each layer connects an implementation choice to the decision or workflow it supports.
06 layers| Layer | Implementation | Operational purpose |
|---|---|---|
| Image pipeline | Grayscale conversion, 128 by 128 resizing and pixel normalization | Apply identical preprocessing during training and inference |
| Data split | Separate training, validation and held-out test datasets | Tune the workflow without contaminating final evaluation evidence |
| Augmentation | Controlled random flips and rotations | Improve robustness to small visual variations in part orientation |
| CNN architecture | Conv2D, MaxPooling2D, dense layers, dropout and sigmoid binary output | Learn local defect patterns with a compact laptop-trainable model |
| Training control | Adam, binary cross-entropy and early stopping on validation loss | Optimize classification while limiting overfitting |
| Evaluation and reuse | Confusion matrix, classification report, single-image prediction and saved model artifacts | Verify class-level performance and support repeatable inference |