All posts

Projects20 min read

Rebuilding PrintGuard's brain: From 9,000 community frames to two new models

How I audited my dissertation model on real printers, worked through a pile of dead ends and trained the new Standard and Light models for PrintGuard 3.0.

Chart comparing PrintGuard 3.0 Standard and Light against Legacy and Obico on 30 unseen printers, showing Standard catching 10 of 20 failed prints at 28.7 ms per frame

In my last post I talked about how PrintGuard grew out of my university dissertation and ended with the feedback inbox I added in version 2.6.0. At that point users had sent in over 5,000 frames from their own printers, and the obvious next job was retraining the model on real data. By late November that bucket had grown to 9,385 frames across 523 prints and 114 different hubs. This is the story of what happened when I finally opened that data, tested my old dissertation model against it and spent a weekend rebuilding the detector from scratch for PrintGuard 3.0.

Opening the inbox: What was actually wrong with version one

When I wrote my dissertation, my ShuffleNetV2 prototypical network looked great on paper. Across four evaluation sets on a Raspberry Pi 4B it scored an F1 of 0.937 at 15.1 images a second, beating Obico's 0.411 at 0.35 images a second. Once people actually started pointing PrintGuard at their own printers, though, the cracks showed up fast. It missed obvious spaghetti on printers that looked different from the training data and fired false alarms on textured beds, grid infill and weird lighting.

Before training anything new I wanted to know why. Auditing the old training code and datasets against those 9,385 real frames turned up four problems that all stacked on top of each other.

First, the shipped prototypes.json file was averaged from just five random good images and five random failure images from the old dataset. One awkward image in a sample of five pulls the whole decision boundary off centre. Second, the old training code had a bug where it cached one random set of augmentations and reused it across every epoch, keyed only by class rather than split, and split the data by individual image instead of by printer or print. Third, the combined public dataset was far smaller than it looked. Out of 26,586 raw images across the seven datasets I had scraped together, 74% were duplicates or Roboflow re-exports of the same photo, leaving only 6,881 unique images, and more than three quarters of those came from one single lab camera. Fourth, a binary prototypical network draws one flat dividing line between "good" and "failing" in 224x224 greyscale space, which forces completely different failures like spaghetti, nozzle blobs, warped corners and detached parts to collapse onto one average point.

I tested whether a quick fix could save the old model before throwing it away. Recomputing the prototypes using the full new training set barely moved the score at all, and even training a brand new linear classifier on top of the frozen version one encoder hit a hard ceiling. The old features just didn't separate real-world prints well enough. To make a real jump I had to start fresh.

Playing fair: A leak-free benchmark and dropping the old data

If there is one lesson from the dissertation that came back to bite me, it's how easy it is to fool yourself with a bad test split. If you split frames randomly, photos from the same printer, camera angle and build plate end up in both training and testing. A model can score 95% just by recognising the background and remembering whether that printer usually failed.

This time I split the 114 hubs strictly by hub ID so that no camera or printer ever appeared in more than one split: 58 hubs for training (6,641 frames), 26 for validation (1,105 frames) and 30 held out as a final test set (1,639 frames). I balanced each split by printer brand (Klipper, Bambu Lab, Prusa, Elegoo, OctoPrint and standalone cameras) and failure volume so one unusual setup couldn't skew the numbers. Every test result was also checked with hub-clustered bootstrapping (resampling whole hubs rather than individual frames, following Field and Welsh, 2007) so I could tell if an improvement actually generalised to unseen printers.

I also changed how I measured accuracy. In my dissertation I used F1 score, which averages precision and recall at a single cutoff. That worked fine on balanced lab datasets, but in real printing only about 10% of frames are failures. When 90% of your frames are normal, accuracy and ROC-AUC can look impressive even while a model spams false alarms every ten minutes. So I switched to PR-AUC (Precision-Recall Area Under the Curve) as the main metric. In plain terms, precision is "when the model shouts failure, how often is it actually right?", recall is "out of all real failures, how many did it catch?", and PR-AUC summarises that trade-off across every possible threshold from 0 to 1. A random guess on this dataset scores about 0.09, and a perfect model scores 1.0. Alongside that, I simulated PrintGuard's actual alert rule (three frames in a row at or above 0.75) over 20 failed prints and 70 good prints to see how many failed prints each model would actually pause and how many good prints it would ruin with a false alarm.

Running the old dissertation model on that unseen test set was humbling. Its 0.937 dissertation F1 turned into a PR-AUC of 0.183, catching just 1 of the 20 failed prints at the default threshold.

I also checked whether I could mix my old public datasets back in to pad out the 58 training hubs. The only reason I used those seven Kaggle and Roboflow datasets for version one in the first place was that there was simply no dataset of multiple different real printers with failures available when I wrote my dissertation. Checking them against the new frames using DINOv2 image embeddings showed why they had held version one back: only 51 out of 6,881 unique images (0.7%) even looked close to real PrintGuard cameras. Trying to train on any single public dataset gave near-random results on real prints, and mixing them 1:1 with community frames cut test PR-AUC in half, from 0.353 down to 0.152. So I dropped the old datasets completely. The new models could not have been trained at all if the community hadn't submitted their frames.

Cleaning up 4,807 frames: Curating the data with Opus 5.5

Real user data is miles better than lab datasets, but it's messy. People naturally leave in frames of an empty build plate before a print starts, mark a couple of harmless wisps of stringing as a failure or miss an actual failure in the middle of a long print. When only 10% of your data is positive, 15% label noise wrecks both training and your test numbers.

Normally you'd be stuck clicking through thousands of images by hand. With how good vision has got in modern AI models, I was able to use Opus 5.5 like a human reviewer instead. Rather than showing it one isolated frame at a time (where even a person can struggle to tell if a part has detached), I stitched each print into a chronological contact sheet so the model could watch the print unfold from start to finish and label every frame against a strict rubric.

Across 255 prints and 4,807 frames, Opus 5.5 caught 723 labels that needed changing (15% of the lot). Most of those were empty beds, homing frames and hands reaching into the chamber that didn't belong in training or testing at all, alongside 84 missed failures and 67 user-marked failures that were actually fine prints. It also tagged each failure by type (spaghetti, detachment, first-layer issues, blobs and stringing) and highlighted the main things tripping up detectors in the wild: grid and honeycomb infill, tree supports, shiny holographic build plates and H.264 video decode glitches.

When the model cheated: Beating background shortcuts

With clean splits ready, I kicked off the first real training run using MobileNetV4-Small. It was a disaster. Training loss dropped smoothly from 0.169 to 0.077 while validation ROC-AUC crashed from 0.563 down to 0.377, worse than flipping a coin.

Looking at the data explained why. Across 58 static cameras, some hubs had a 0.5% failure rate while others sat at 73%. When you unfreeze an entire network straight away with a brand new random classification head, the big early gradients wreck the general visual features the model brought from ImageNet (a problem documented by Kumar et al. in their 2022 LP-FT paper) and the network takes the easiest shortcut available (Geirhos et al., 2020): it memorises each printer's enclosure, lighting and bed texture and guesses "this hub usually fails" instead of learning what spaghetti looks like. On top of that, an exponential moving average wrapper was blending stale BatchNorm statistics with fast-moving weights.

Curiously, this mirrored something I had stumbled into during my dissertation without fully understanding it at the time. Back then, fine-tuning my ShuffleNetV2 encoder on 3D print images actually made it worse than leaving the ImageNet weights alone and training gently. Now I had both the real reason why and a proper fix.

I made three changes to force the model to look at the print rather than the printer:

  • Linear probe then fine-tune (LP-FT): freeze the backbone first so the classification head learns a sensible boundary without trashing the pretrained features, then gently unfreeze the backbone at a much lower learning rate.
  • Per-hub class balancing: weight good and failed frames evenly within each hub so a printer that uploaded lots of failures can't bias the model toward its background.
  • Within-print pairwise ranking: pair a failed frame with a good frame from the exact same print and train the model to score the failure higher. Because both frames share the same camera, lighting and bed, the background mathematically cancels out.

That single set of changes turned a collapsing run into a working model, jumping Gold Test PR-AUC from version one's 0.183 up to 0.431.

Every pixel counts: Framing, colour and local pooling

Once the model stopped cheating, a string of simple visual fixes drove the next big gains.

First was cropping. Most PrintGuard cameras are 16:9 widescreen, and my first runs letterboxed them into a square with black bars top and bottom, throwing away two thirds of the pixels. Switching to a centre crop gave the model more than three times as many pixels on the actual print bed (and matched what PrintGuard already passes at runtime). That alone jumped Gold PR-AUC from 0.431 to 0.578. Plugging in the Opus-curated labels pushed it to 0.600 and cut calibration error in half.

Next was how the model turns a feature map into a single score. A normal image classifier averages all the spatial patches across the frame (7x7 patches in ConvNeXt-Atto). That's fine if you're classifying a photo of a dog that fills the screen, but a small nozzle blob or early spaghetti strand might only occupy two or three patches out of 49, so averaging dilutes it into nothing. Borrowing from Multiple Instance Learning (Ilse et al., 2018), I swapped average pooling for LogSumExp spatial pooling, which behaves like a smooth maximum across the image so a single failing region can drive the prediction. That jumped Gold PR-AUC from 0.600 to 0.649, leaving just one false positive in the top 30 predictions.

This was also where my new results directly contradicted my dissertation. In my dissertation I converted everything to greyscale so the model would focus on texture instead of filament colour, and under standard average pooling here greyscale actually did beat RGB again (0.629 vs 0.600). The moment I combined greyscale with local LogSumExp pooling, though, it fell apart, dropping to 0.529. Without colour information, local max pooling latched onto bright white specular glare on shiny beds and fired confidence scores above 0.99. Keeping RGB gave the model the colour contrast it needed to tell reflections apart from filament. I also tested bumping input resolution from 224px to 288px, expecting sharper spaghetti strands to help, but 224px beat it (0.649 vs 0.626) while running 1.55x faster because it matched the backbone's pretrained receptive field.

How the same small spaghetti defect moves through Legacy (top) compared with PrintGuard 3.0 Standard (bottom).

Finding the right backbone: Sweeping edge architectures

PrintGuard has to run on cheap hardware like a Raspberry Pi without a GPU, so I benchmarked five modern edge backbones on a single CPU thread: MobileNetV4-Small, EfficientNetV2-B0, ConvNeXt-Atto, ConvNeXt-Femto and FastViT-T8.

Along the way I hit one more subtle bug. Every model that used BatchNorm collapsed again during fine-tuning because alternating normal training batches with 50%-positive ranking batches kept jerking BatchNorm's running mean and variance back and forth. Freezing BatchNorm statistics during fine-tuning fixed it immediately and rescued MobileNetV4-Small from 0.175 validation PR-AUC up to 0.549.

Out of the five, two clear winners stood out. ConvNeXt-Atto (3.37M parameters, 12.9 MB) took the top spot on unseen test hubs at 0.649 PR-AUC. It uses LayerNorm instead of BatchNorm so it never suffered from batch-stat drift, and its size turned out to be the sweet spot for 58 training hubs. Even the slightly larger ConvNeXt-Femto (4.83M) scored higher on validation (0.799) but dropped to 0.570 on unseen test hubs because it had enough spare capacity to overfit. At the fast end, MobileNetV4-Small (2.49M, 9.5 MB) ran in around 10 ms on one CPU thread, nearly three times faster than ConvNeXt-Atto, making it the obvious candidate for slower hardware.

Two panels showing the colour vs pooling 2x2 ablation matrix on ConvNeXt-Atto where RGB with LogSumExp leads at 0.649 while greyscale with LogSumExp drops to 0.529, alongside a bar chart of the five edge backbones swept before distillation

Standing on giants' shoulders: Teachers, distillation and model soups

Even with all those fixes, a tiny 3.4M-parameter CNN trained on 58 hubs hits a ceiling on how well it can generalise to brand new printers. Giant self-supervised vision transformers like Meta's DINOv2 (Oquab et al., 2024) don't have that problem because they already understand 3D shapes and textures from pretraining on 142 million images. When I froze DINOv2-Base (85.7M parameters) completely and trained just a tiny 769-parameter linear head on top, it hit 0.772 Gold PR-AUC and 0.926 ROC-AUC without memorising a single hub. Interestingly, that echoed my dissertation's discovery that keeping strong pretrained features completely frozen can beat fine-tuning when your dataset is small.

Obviously nobody is running an 86M-parameter vision transformer on a Raspberry Pi CPU. Instead, I used knowledge distillation (Hinton et al., 2015), training big teacher models and teaching our small edge models to match their soft probability outputs alongside the real labels.

My first attempt failed in a textbook way. Distilling the huge DINOv2-Base vision transformer straight into tiny ConvNeXt-Atto actually scored worse than training without distillation at all (0.591 vs 0.649). Research by Cho and Hariharan (2019) and Mirzadeh et al. (2020) explains why: when the gap in size and architecture between a giant ViT teacher and a tiny CNN student is too wide, the student can't mimic the teacher's decision surface cleanly.

Bridging that gap with a three-teacher ensemble solved it. I combined frozen DINOv2-Base (85.7M), mid-sized frozen DINOv2-Small (21.6M) and a CNN teacher, ConvNeXt-Nano pretrained on ImageNet-12k (15.0M), then distilled their averaged predictions at a softer temperature (T = 2.5). That unlocked huge jumps on both edge backbones:

  • MobileNetV4-Small jumped by 14.4 points, from 0.469 to 0.613 Gold PR-AUC, more than doubling its recall at 80% precision in under 10 ms on a single CPU thread. That became the new Light model.
  • ConvNeXt-Atto jumped from 0.649 to 0.713 Gold PR-AUC across three different random seeds, actually beating both the 21.6M DINOv2-Small teacher and the 15M ConvNeXt-Nano teacher on unseen test hubs while running more than five times faster than DINOv2-Small.
Diagram showing DINOv2-Base, DINOv2-Small and ConvNeXt-Nano averaged into temperature 2.5 ensemble soft targets to train Standard (ConvNeXt-Atto, 0.722 PR-AUC) and Light (MobileNetV4-Small, 0.613 PR-AUC)

One last trick squeezed out a bit more accuracy for free. Because different random seeds learnt slightly different strengths across the 58 hubs, I used model souping (Wortsman et al., 2022), which averages the weights of multiple fine-tuned runs from the same training basin into a single set of weights. Picking strictly by validation score, averaging two distilled ConvNeXt-Atto seeds pushed Gold Test PR-AUC to 0.722 and ROC-AUC to 0.920 with zero extra inference cost. That became the new Standard model. Finally, I calibrated both models with temperature scaling (Guo et al., 2017) on validation so that PrintGuard's default 0.75 alert threshold behaves consistently whichever model you pick.

Horizontal bar chart tracking Gold Test PR-AUC step by step from Legacy at 0.183 through anti-shortcut training (0.431), centre-crop RGB (0.578), Opus 5.5 curation (0.600), LogSumExp pooling (0.649), 3-teacher distillation (0.713) and model souping to Standard at 0.722

Reality check: Exporting, dropping INT8 and benchmarking against Obico

PrintGuard bundles every model twice, once for ONNX Runtime (which uses Core ML on Mac, OpenVINO on Intel, DirectML/Windows ML on Windows or TensorRT on NVIDIA) and once for LiteRT (Google's optimised CPU runtime), benchmarking both on startup to keep whichever is faster on your machine. I exported both Standard and Light to FP32 ONNX and LiteRT and ran all four files over all 1,639 test frames. Every single export matched PyTorch within 4.7e-6 and agreed on 1,639 out of 1,639 alert decisions at 0.75.

I also tested an INT8 dynamic quantised build of Standard to see if shrinking it from 13 MB down to 3.6 MB was worth it. It wasn't. On CPU it only saved about 6 ms per frame, dynamic quantisation drops back to CPU on Core ML and GPU providers, and it shifted individual frame scores by up to 0.52, flipping 20 alert decisions against FP32. Dropping it was an easy call.

Finally, I wanted an honest head-to-head against Obico on the exact same 30 unseen hubs. Obico's newer cloud model from May 2026 has no public weights, so I tested both of its open-source weights (the May 2023 ONNX build and the December 2025 darknet build). I reimplemented Obico's exact frame scoring (NMS 0.45 and summing box confidences above 0.08, verified to 2.3e-6 against Obico's own containers) and, since Obico's scores aren't probabilities, picked its print-level threshold on validation to match Standard's precision at 0.75.

Model Size Mac 1-thread CPU Gold PR-AUC ROC-AUC Failed prints caught Good prints alarmed
Standard 12.9 MB 28.7 ms 0.722 0.920 10 of 20 1 of 70
Light 9.5 MB 11.2 ms 0.613 0.858 5 of 20 1 of 70
Legacy (v1) 4.8 MB 5.3 ms 0.183 0.746 1 of 20 1 of 70
Obico (Dec 2025) 193 MB 360 ms 0.628 0.820 3 of 20 0 of 70
Obico (May 2023) 193 MB 359 ms 0.603 0.816 6 of 20 0 of 70

Standard is nearly four times the PR-AUC of Legacy, catches ten times as many failed prints with the exact same single false alarm out of 70 good prints, and beats Obico's December 2025 model while being 12 times faster on CPU and 15 times smaller. Even Light sits right alongside Obico on frame-level PR-AUC and beats it on ROC-AUC at over 30 times the speed.

And in actual use on my Raspberry Pi 5 running PrintGuard with camera augmentations enabled, Standard runs at around 40 fps and Light hits around 60 fps, with the whole container peaking at about 500 MB of RAM. That's a far cry from needing a dedicated GPU and 4 GB of RAM.

Two panels comparing PrintGuard 3.0 against Obico on 30 unseen hubs: a scatter plot of PR-AUC against log CPU latency showing Standard 12x faster and 15x smaller than Obico, and a bar chart of failed prints caught out of 20

How I used AI for this research

Just like in my last post, I want to be upfront about where AI fit into this. When I trained the first PrintGuard model at uni I was studying machine learning full time and had months to sit in papers and notebooks by myself. I have other commitments now and simply don't have the hours to do a literature review, manually label five thousand photos and babysit thirty training runs alone.

Opus 5.5 did the heavy lifting on image curation and labelling, reviewing all 4,807 frames through the contact sheets. I used both Opus 5.5 and Gemini 4 Neon to hunt down relevant research papers and summarise them for me (things like LP-FT, spatial MIL, cross-architecture distillation and model soups) so I could connect the ideas together, plan the experiments and decide what to test next. After each batch of training runs, Opus agents broke down the metrics and built visual charts and reports so I could scan the results at a high level, spot what had gone wrong and pick the next route without drowning in JSON logs. The goals, constraints, architecture calls and product trade-offs were mine, and agents acted like a very fast research assistant keeping the loop moving.

Where we're at now: PrintGuard 3.0 and what's next

Standard, Light and Legacy are all coming out together in PrintGuard 3.0, the next major version. Standard is the new default, Light is there for slower machines or multi-camera setups, and Legacy stays available if you want the original model. You pick between them during first-run setup or in Settings, where PrintGuard shows the benchmark chart right beside your host's live capacity readout. Alongside the new models, 3.0 also brings a full UI overhaul. Since 2.0 came out so many new features got piled into the dashboard that the original layout had started to feel cluttered and janky, so it was time to clean the whole thing up properly.

The Detection tab in PrintGuard 3.0 Settings showing Standard, Light and Legacy cards above a benchmark chart comparing them against Obico

I'm really happy with how far the detector jumped, though I don't want to oversell it. Catching 10 out of 20 failed prints on unseen printers is a huge step up from 1 out of 20, but it still means half of real-world failures slip past, especially subtle first-layer issues and nozzle blobs. 58 training hubs is still a small dataset for the sheer variety of printers, cameras and lighting people use. One early diagnostic I ran during this research also showed a big jump when giving the model the difference between the current frame and the first frame of the print, which helps with static build plate false alarms and air printing. That's high on my list to explore next once more prints come in.

A massive thank you to everyone who opted in and sent frames through the review sheet. Version one proved the idea, but this new model genuinely belongs to the community. If you run PrintGuard and don't mind sharing frames after a print finishes, every new printer and camera angle makes the next version better for everyone. PrintGuard is on GitHub if you want to check it out.

References

Bravery, O.J. (2025) Few-shot Classification for Real-time Additive Manufacturing Fault Detection on Edge Devices. BSc dissertation, Newcastle University. Available at: https://github.com/oliverbravery/Edge-FDM-Fault-Detection/blob/main/dissertation.pdf (Accessed: 22 November 2026).

Cho, J.H. and Hariharan, B., 2019. On the efficacy of knowledge distillation. In Proceedings of the IEEE/CVF international conference on computer vision (ICCV) (pp. 4793-4801).

Field, C.A. and Welsh, A.H., 2007. Bootstrapping clustered data. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 69(3), pp.369-390.

Geirhos, R., Jacobsen, J.H., Michaelis, C., Zemel, R., Brendel, W., Bethge, M. and Wichmann, F.A., 2020. Shortcut learning in deep neural networks. Nature Machine Intelligence, 2(11), pp.665-673.

Guo, C., Pleiss, G., Sun, Y. and Weinberger, K.Q., 2017. On calibration of modern neural networks. In International conference on machine learning (ICML) (pp. 1321-1330). PMLR.

Hinton, G., Vinyals, O. and Dean, J., 2015. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531.

Ilse, M., Tomczak, J. and Welling, M., 2018. Attention-based deep multiple instance learning. In International conference on machine learning (ICML) (pp. 2127-2136). PMLR.

Kumar, A., Raghunathan, A., Jones, R., Ma, T. and Liang, P., 2022. Fine-tuning can distort pretrained features and underperform out-of-distribution. In International conference on learning representations (ICLR).

Liu, Z., Mao, H., Wu, C.Y., Feichtenhofer, C., Darrell, T. and Xie, S., 2022. A convnet for the 2020s. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition (CVPR) (pp. 11966-11976).

Ma, N., Zhang, X., Zheng, H.T. and Sun, J., 2018. Shufflenet v2: Practical guidelines for efficient cnn architecture design. In Proceedings of the European conference on computer vision (ECCV) (pp. 116-131).

Mirzadeh, S.I., Farajtabar, M., Li, A., Levine, N., Matsukawa, A. and Ghasemzadeh, H., 2020. Improved knowledge distillation via teacher assistant. In Proceedings of the AAAI conference on artificial intelligence, 34(04), pp.5191-5198.

Obico (2025) The Obico Server, GitHub. Available at: https://github.com/TheSpaghettiDetective/obico-server (Accessed: 21 November 2026).

Oquab, M., Darcet, T., Moutakanni, T., Vo, H., Szafraniec, M., Khalidov, V., Fernandez, P., Haziza, D., Massa, F., El-Nouby, A., Assran, M., Ballas, N., Galuba, W., Howes, R., Huang, P.Y., Li, S.W., Misra, I., Rabbat, M., Sharma, V., Synnaeve, G., Xu, H., Jegou, H., Mairal, J., Labatut, P., Joulin, A. and Bojanowski, P., 2024. DINOv2: Learning robust visual features without supervision. Transactions on Machine Learning Research.

Qin, D., Leichner, C., Delakis, M., Fornoni, M., Luo, S., Yang, F., Wang, W., Banbury, C., Ye, C., Akin, B., Aggarwal, V., Zhu, T., Moro, D. and Howard, A., 2024. MobileNetV4: Universal models for the mobile ecosystem. In Proceedings of the European conference on computer vision (ECCV) (pp. 78-96). Springer.

Snell, J., Swersky, K. and Zemel, R., 2017. Prototypical networks for few-shot learning. Advances in neural information processing systems, 30.

Tan, M. and Le, Q., 2021. Efficientnetv2: Smaller models and faster training. In International conference on machine learning (ICML) (pp. 10096-10106). PMLR.

Vasu, P.K.A., Gabriel, J., Zhu, J., Tuzel, O. and Ranjan, A., 2023. FastViT: A fast hybrid vision transformer using structural reparameterization. In Proceedings of the IEEE/CVF international conference on computer vision (ICCV) (pp. 5762-5772).

Wortsman, M., Ilharco, G., Gadre, S.Y., Roelofs, R., Gontijo-Lopes, R., Morcos, A.S., Namkoong, H., Farhadi, A., Carmon, Y., Kornblith, S. and Schmidt, L., 2022. Model soups: averaging weights of multiple fine-tuned models improves accuracy without increasing inference time. In International conference on machine learning (ICML) (pp. 23965-23998). PMLR.

Back to all posts