How can I change the architecture of YOLOv8

Hi, I’m doing an object detection project with YOLOv8.
I’d like to know if there’s a way to change the model architecture and the connections between the layers. I know that I can download models of different sizes but I’m more interested in having access to the implementation of the architecture.

Hi @David, for customization of the architecture to that level, you’ll want to use the official YOLOv8 docs: Advanced customization - YOLOv8 Docs

https://docs.ultralytics.com/cfg/

Thanks for the answer but I don’t see any possible architecture change in the advanced customization. Where specifically in the advanced customization have you seen that it’s possible to change the architecture?

There’s the train.py file right here: ultralytics/train.py at main · ultralytics/ultralytics · GitHub, and the default config: ultralytics/default.yaml at main · ultralytics/ultralytics · GitHub.

For a full look at the architecture itself, here’s our blog post on YOLOv8: What is YOLOv8? The Ultimate Guide.

I’m not completely sure where the spot in the code is, myself. It may be best to post on the Ultralytics forum for this one.

Thank you. As far as I know, you can only load a model. Apparently you can’t edit one.

You can load in a custom architecture via a YAML file, from what I can see:

from ultralytics import YOLO

# Load a model
model = YOLO("yolov8n.yaml")  # build a new model from scratch

More hyparameters can also be tuned with the YAML file: Configuration - YOLOv8 Docs

  • “Training settings for YOLO models refer to the various hyperparameters and configurations used to train the model on a dataset. These settings can affect the model’s performance, speed, and accuracy.”