Deploying YOLOv8 with a custom backbone in Flask without module import errors

rdEliza
Fri, 31 Oct 2025 11:28:04 +0000
Support

I have trained a YOLOv8 model but modified its backbone by adding a custom component (APConv). I want to deploy this model using Flask so it can receive images and return object counts. When I try to load the model with YOLO('best.pt') in Flask, I encounter module import errors for the custom layers, even though I have added the .py file for APConv.

My Flask code includes routes for uploading images and running inference, but the model fails to load due to missing custom modules. I need guidance on the best way to load or package the model for deployment so that my custom layers are recognized and inference works without errors.

6 posts - 4 participants

Read full topic