TorchScript error: "The size of tensor a (3549) must match the size of tensor b (8400)" using YOLOv8 model on Android with PyTorch Mobile

Cause and Fix Table
Cause Fix
Wrong input size on Android Resize image to 640×640 or same as export size
Static model exported with different size Re-export model with correct input size
Mismatch in postprocessing logic Align indexing/shapes to expected YOLO output tensor