and After pruning my YOLO model, Ultralytics can’t load it due to shape/key mismatches. Can pruned models still be validated with model.val()?
No. It would work only if you export the pruned model manually to ONNX.
thank you
You’re welcome!
Just to add a small clarification: Ultralytics YOLO models don’t currently have built‑in pruning utilities or support for loading structurally pruned checkpoints, so once pruning changes tensor shapes or module structure you can’t reload them into YOLO() or use model.val(), as Toxite mentioned. If you only do unstructured pruning (weights are zeroed but shapes stay the same), the original Ultralytics model can still be loaded and validated; most structured channel/filter pruning will not.
For pruned architectures, treat the network as a standard PyTorch model, export it manually to ONNX with torch.onnx.export, and validate or benchmark it using your own loop or an engine like ONNX Runtime. If you want a quick conceptual refresher on how pruning works with YOLO-style models, the Ultralytics model pruning overview gives a concise summary.