Adding a new head to the YOLO11n model

I used this head Detect_LSDECD (I used it because its light) with YOLO11 and added the P2 to detect the small object. When the training completed I got on this results:

Speed: 0.1ms preprocess, 0.7ms inference, 0.0ms loss, 0.9ms postprocess per image

but When use this code :

model = YOLO("best.pt") 

source = "resized.jpg"

results = model(source)

This is the output:

Speed: 2.3ms preprocess, 13.2ms inference, 1.5ms postprocess per image at shape (1, 3, 640, 640)


Please how can I decrease the inference time?

Hard to say when you’ve modified the model. You could try rerunning validation like it would at the end of training to see if you can replicate the same speeds. If so, then you’d want to ensure to use the same inference arguments as validation for inference.

Depending on your device and layer compatibility, you could try to export to TensorRT for NVIDIA GPUs, but with a modified model, there’s not guarantee it will work. If not using a NVIDIA GPU, you could try exporting to a format that’s more optimized for the specific hardware you’re using.

That’s a fork of the official repository. You’ll need to contact the maintainer for assistance, we can only provide support for the official Ultralytics repository. Like I mentioned before, you can try exporting to a model format like TensorRT for faster inference for NVIDIA hardware, or what’ever inference hardware you’ll be using.