3D-Print Defect Detection β Stringing CNN (YOLO-Strings)
A small convolutional neural network that classifies a photo of an FDM 3D print as a good print or a stringing defect (thin strands of filament left between printed sections β wasted material and post-processing time). 106k parameters, trained from scratch on CPU; input is a 64Γ64 grayscale image.
Classes
good printβ no stringing (1,611 images)stringingβ stringing defect visible (5,425 images)
Results
| Model | Test accuracy | Macro F1 |
|---|---|---|
| PrintDefectCNN (this model) | 95.73% | 89.08% |
| Logistic regression on 48Γ48 grayscale pixels | 97.02% | 93.59% |
| Always-majority baseline | 86.87% | β |
Per-class F1 β good print: 80.56% Β· stringing: 97.60%. At the default threshold the model catches every stringing defect in the test set (100% recall on the defect class) at the cost of some false alarms on good prints β the right trade-off for defect screening, where a missed defect wastes a whole print.
Generalisation tests (train/test from the same distribution is the easy part):
- Unseen prints β the split is by physical print sequence (19/4/5 sequences for train/val/test), so no near-duplicate frames leak into the test set. The numbers above are already cross-print.
- Unseen camera β trained on FLIR-camera frames, tested on microscope frames (different sensor, view and magnification): 89.54%. A genuine domain gap, reported as an open problem (next step: domain adaptation).
- Honest negative result: an RGB variant of this CNN memorised print-specific colours and collapsed to 54% on unseen prints. Switching to grayscale + random-crop augmentation fixed it β colour was a spurious cue.
Usage
from model import load_model, predict_image, CLASS_NAMES
model = load_model("pytorch_model.bin") # CPU by default
# image: file path, PIL image, or numpy array (any size, colour or gray)
cls_id, probs = predict_image(model, "my_print.jpg")
print(CLASS_NAMES[cls_id], f"{probs[cls_id]:.1%} confidence")
Preprocessing contract (must match training): convert to grayscale, resize
to 64Γ64, ToTensor(), Normalize(mean=0.5, std=0.5). The helper
predict_image does this for you.
Training details
- Data: YOLO-Strings (Charia et al., 2025),
datasets/sequences/tree β 7,036 real FDM print photos from 28 print sequences (FLIR camera + microscope). Labels from the published directory layout (with_stringing/without_stringing). Zenodo DOI: 10.5281/zenodo.14711320. - Split: group split by print sequence, 70/15/15 β all frames (both cameras, both labels) of one physical print stay in one split; prevents temporal leakage from near-duplicate consecutive frames.
- Optimiser: Adam (lr 1e-3, weight decay 1e-4, cosine schedule),
class-weighted loss, augmentation = horizontal flips + random resized crops
- brightness jitter, early stopping on validation accuracy.
- Full reproducible pipeline (data loader, training, baselines, figures): see the project repository.
Limitations
- Binary task (stringing vs good) β does not distinguish other FDM defects (layer shift, warping, under-extrusion).
- Lab/controlled photos; sensitive to lighting, background clutter and extreme close-ups unlike the training views.
- Microscope-view generalisation is partial (89.5%) β the model was trained mostly on FLIR-style views.
- The two classes come from the dataset authors' directory labels; "good" frames are early layers of prints that later developed stringing.
Citation
Data: Charia, O., Rajani, H., Ferrer Real, I., Domingo-Espin, M., & Gracias, N. (2025). "Real-Time Stringing Detection for Additive Manufacturing." Journal of Manufacturing and Materials Processing, 9(3). Dataset: YOLO-Strings, Zenodo https://doi.org/10.5281/zenodo.14711320.
Built as a portfolio project for graduate applications in intelligent manufacturing / additive-manufacturing process monitoring (mechanical engineering Γ AI).
- Downloads last month
- 265
