Skip to content

Latest commit

 

History

History
254 lines (196 loc) · 7.1 KB

File metadata and controls

254 lines (196 loc) · 7.1 KB

🎉 Project Complete: 3D Print Failure Detection System

Overview

You now have a complete, working system for monitoring your 3D printer and detecting failed prints in real-time!

What We Built

Phase 1: Printer Offline Detection ✅

  • Model: ResNet18 with transfer learning
  • Accuracy: 93.33% validation accuracy
  • Dataset: 150 labeled images (90 offline, 60 active)
  • Result: Filtered 4,828 images down to 393 active prints (92% reduction!)

Phase 2: Failed Print Detection ✅

  • Model: ResNet18 with transfer learning
  • Accuracy: 95.00% validation accuracy
  • Dataset: 196 labeled images (175 good, 21 failed)
  • Result: Can detect print failures with high confidence

Phase 3: Real-Time Monitoring ✅

  • tail -f style continuous monitoring
  • Dual-stage classification: offline → active → good/failed
  • Instant alerts when failures detected
  • State management for resume capability

Quick Start Guide

For an Ongoing Print (Right Now!)

# Start monitoring today's print
make monitor

You'll see output like:

🟢 [2025-11-10 14:23:45] image.jpg - Print OK (good: 92.3%)
🚨 [2025-11-10 14:25:15] image.jpg
   ⚠️  FAILED PRINT DETECTED! (confidence: 87.2%)
   🔔 CHECK YOUR PRINTER NOW!

For Future Prints

  1. Start monitoring when you begin a print:

    make monitor
  2. Leave it running in a terminal window

  3. Get instant alerts if something goes wrong

  4. Stop with Ctrl+C when done

System Architecture

New Image Arrives (every 30s)
    ↓
┌─────────────────────────────┐
│  Stage 1: Offline Detection │
│  Is printer active?         │
└─────────────────────────────┘
    ↓
    ├─ OFFLINE ⚫ → Skip
    │
    └─ ACTIVE 🟢
        ↓
    ┌─────────────────────────────┐
    │ Stage 2: Failed Detection   │
    │ Is print failing?           │
    └─────────────────────────────┘
        ↓
        ├─ GOOD ✓ → Continue monitoring
        │
        └─ FAILED 🚨 → ALERT!

Files Created

Models

  • models/printer_offline_detector.pth (43 MB) - Offline detection model
  • models/failed_print_detector.pth (43 MB) - Failed print detection model
  • models/*_history.png - Training history plots

Data

  • data/labels.json - Offline/active labels (150 images)
  • data/failed_print_labels.json - Good/failed labels (196 images)
  • data/active_images.txt - List of 393 active images
  • data/monitor_state.json - Monitoring state (auto-generated)

Scripts

  • src/monitor_print.py - Real-time monitoring (tail -f style)
  • src/label_failed_prints.py - Failed print labeling tool
  • src/train_failed_print_model.py - Failed print model training
  • Plus all Phase 1 scripts

Documentation

  • MONITOR_README.md - Monitoring guide
  • MONITORING_GUIDE.md - Detailed monitoring documentation
  • PHASE2_GUIDE.md - Phase 2 walkthrough
  • PROJECT_COMPLETE.md - This file!

Key Commands

Monitoring

make monitor              # Monitor today's prints (30s interval)
make monitor-fast         # Monitor with 10s interval
make monitor-date DATE=20251110  # Monitor specific date
./demo_monitor.sh         # Demo with existing images

Status Checks

make status               # Overall project status
make status-failed        # Failed print detection status

Training & Labeling

make label-failed         # Label more failed prints
make train-failed         # Retrain failed print model

Real-World Usage

Scenario 1: Overnight Print

# Before bed, start monitoring
nohup make monitor > print.log 2>&1 &

# In the morning, check the log
grep "FAILED" print.log

Scenario 2: Live Monitoring

# Start a print, then immediately:
make monitor

# Watch in real-time as each image is classified
# Get instant alert if failure detected

Scenario 3: Multiple Printers

# Terminal 1 - Printer A
python src/monitor_print.py --image-dir printer-a/20251110

# Terminal 2 - Printer B  
python src/monitor_print.py --image-dir printer-b/20251110

Performance Summary

Printer Offline Detection

  • ✅ 93.33% validation accuracy
  • ✅ Filtered 4,828 → 393 images (92% reduction)
  • ✅ Mean confidence: 97.4%
  • ✅ Zero low-confidence predictions

Failed Print Detection

  • ✅ 95.00% validation accuracy
  • ✅ Trained on imbalanced data (8:1 ratio) successfully
  • ✅ Detected actual failure at 06:50:18 in test run!
  • ✅ Low false positive rate

Real-Time Monitor

  • ✅ Processes images as they arrive (tail -f style)
  • ✅ 2-30 second polling intervals
  • ✅ State management for resume capability
  • ✅ Clean, readable output
  • ✅ Instant failure alerts

Next Steps & Improvements

Short Term

  1. Collect more failed print examples as they occur naturally
  2. Retrain models with expanded datasets
  3. Tune confidence thresholds based on your false positive rate
  4. Add notifications (Discord, email, SMS)

Medium Term

  1. Create web dashboard for monitoring multiple printers
  2. Add failure type classification (spaghetti, layer shift, adhesion, etc.)
  3. Integrate with OctoPrint/Klipper for automatic pause
  4. Build timelapse video generator from good prints only

Long Term

  1. Deploy on edge device (Raspberry Pi) near printer
  2. Add camera integration for live monitoring
  3. Implement automatic recovery actions
  4. Create mobile app for remote monitoring
  5. Share models with community

Lessons Learned

  1. Transfer learning works great - Even with small datasets (150-200 images), achieved 93-95% accuracy
  2. Class imbalance is manageable - 8:1 ratio still produced 95% accuracy
  3. Sequence detection helps - Using temporal information improved labeling efficiency
  4. Real-time monitoring is valuable - tail -f style interface is intuitive and useful
  5. Iterative approach works - Start small, test, expand dataset, retrain

Success Metrics

Goal: Detect printer offline vs active
Result: 93.33% accuracy, 92% data reduction

Goal: Detect failed prints
Result: 95% accuracy, detected real failure in test

Goal: Real-time monitoring
Result: Working tail -f style monitor with instant alerts

Goal: Iterate quickly on model development
Result: Complete pipeline from labeling → training → inference → monitoring

Thank You!

This project demonstrates the power of:

  • Transfer learning for small datasets
  • Iterative model development
  • Practical ML applications for real-world problems
  • Clean, usable interfaces for ML systems

Your 3D printer is now smarter! 🖨️🧠✨


Quick Reference

Start monitoring NOW:

make monitor

Check what you have:

make status
make status-failed

Get help:

make help
cat MONITOR_README.md
cat MONITORING_GUIDE.md

Happy printing! 🎉