Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML config file cleanups #10163

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from
Draft

Conversation

Burhan-Q
Copy link
Member

@Burhan-Q Burhan-Q commented Apr 18, 2024

  • Removes multiple (19 total) YAML files for model configurations
  • Single file to manage all YOLO models
  • Adds new function to stack new file layout model layers
  • Update maintains backward compatibility with other model configuration files
  • Uses YAML aliasing to avoid repeating data
  • Adds YOLOv8-obb-p2 and YOLOv8-obb-p6 configurations (working, but performance not tested)
  • Updated pytests for compatibility with new format
  • Add inference test to non-RTDETR models loaded by YAML in pytests (wasn't clear if this was missing or not, but seemed like a good test to include).
pytest report

Note output here displays YAML for display and troubleshooting purposes, but this change was not included in this PR

========================================================================================== test session starts ===========================================================================================
platform win32 -- Python 3.10.9, pytest-7.4.3, pluggy-1.3.0
rootdir: .
configfile: pyproject.toml
plugins: cov-4.1.0
collected 1 item

tests/test_python.py rtdetr-l.yaml
WARNING ⚠️ no model scale passed. Assuming scale='l'.

image 1/1 /ultralytics/assets/bus.jpg: 640x640 (no detections), 25.0ms
Speed: 2.0ms preprocess, 25.0ms inference, 3.0ms postprocess per image at shape (1, 3, 640, 640)
rtdetr-resnet101.yaml
WARNING ⚠️ no model scale passed. Assuming scale='l'.

image 1/1 /ultralytics/assets/bus.jpg: 640x640 (no detections), 31.0ms
Speed: 4.0ms preprocess, 31.0ms inference, 1.0ms postprocess per image at shape (1, 3, 640, 640)
rtdetr-resnet50.yaml
WARNING ⚠️ no model scale passed. Assuming scale='l'.

image 1/1 /ultralytics/assets/bus.jpg: 640x640 (no detections), 26.0ms
Speed: 3.0ms preprocess, 26.0ms inference, 0.0ms postprocess per image at shape (1, 3, 640, 640)
rtdetr-x.yaml
WARNING ⚠️ no model scale passed. Assuming scale='x'.

image 1/1 /ultralytics/assets/bus.jpg: 640x640 (no detections), 32.0ms
Speed: 3.0ms preprocess, 32.0ms inference, 1.0ms postprocess per image at shape (1, 3, 640, 640)
yolov3.yaml

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 137.0ms
Speed: 1.0ms preprocess, 137.0ms inference, 537.0ms postprocess per image at shape (1, 3, 160, 128)
yolov3-spp.yaml

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 12.0ms
Speed: 0.0ms preprocess, 12.0ms inference, 0.0ms postprocess per image at shape (1, 3, 160, 128)
yolov3-tiny.yaml

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 46.0ms
Speed: 1.0ms preprocess, 46.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
yolov5.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 96.0ms
Speed: 0.0ms preprocess, 96.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
yolov5-p6.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

WARNING ⚠️ imgsz=[160] must be multiple of max stride 64, updating to [192]
image 1/1 /ultralytics/assets/bus.jpg: 192x192 (no detections), 9.0ms
Speed: 0.0ms preprocess, 9.0ms inference, 0.0ms postprocess per image at shape (1, 3, 192, 192)
yolov6.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 54.0ms
Speed: 1.0ms preprocess, 54.0ms inference, 0.0ms postprocess per image at shape (1, 3, 160, 128)
yolov8.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 27.0ms
Speed: 0.0ms preprocess, 27.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
yolov8-cls.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.
YOLOv8 summary: 99 layers, 1540768 parameters, 1540768 gradients, 3.4 GFLOPs

image 1/1 /ultralytics/assets/bus.jpg: 160x160 33 0.01, 27 0.01, 79 0.01, 10 0.01, 5 0.01, 5.0ms
Speed: 7.0ms preprocess, 5.0ms inference, 0.0ms postprocess per image at shape (1, 3, 160, 160)
yolov8-cls-resnet101.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.
YOLOv8 summary: 436 layers, 45226640 parameters, 45226640 gradients, 130.6 GFLOPs

image 1/1 /ultralytics/assets/bus.jpg: 160x160 32 0.01, 10 0.01, 28 0.01, 74 0.01, 5 0.01, 14.0ms
Speed: 6.0ms preprocess, 14.0ms inference, 0.0ms postprocess per image at shape (1, 3, 160, 160)
yolov8-cls-resnet50.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.
YOLOv8 summary: 232 layers, 26234512 parameters, 26234512 gradients, 69.6 GFLOPs

image 1/1 /ultralytics/assets/bus.jpg: 160x160 66 0.01, 78 0.01, 43 0.01, 79 0.01, 48 0.01, 12.0ms
Speed: 5.0ms preprocess, 12.0ms inference, 0.0ms postprocess per image at shape (1, 3, 160, 160)
yolov8-ghost.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 52.0ms
Speed: 0.0ms preprocess, 52.0ms inference, 0.0ms postprocess per image at shape (1, 3, 160, 128)
yolov8-ghost-p2.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 38.0ms
Speed: 0.0ms preprocess, 38.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
yolov8-ghost-p6.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

WARNING ⚠️ imgsz=[160] must be multiple of max stride 64, updating to [192]
image 1/1 /ultralytics/assets/bus.jpg: 192x192 (no detections), 13.0ms
Speed: 0.0ms preprocess, 13.0ms inference, 1.0ms postprocess per image at shape (1, 3, 192, 192)
yolov8-obb.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 37.0ms
Speed: 0.0ms preprocess, 37.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
yolov8-obb-p2.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 43.0ms
Speed: 0.0ms preprocess, 43.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
yolov8-obb-p6.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

WARNING ⚠️ imgsz=[160] must be multiple of max stride 64, updating to [192]
image 1/1 /ultralytics/assets/bus.jpg: 192x192 (no detections), 17.0ms
Speed: 1.0ms preprocess, 17.0ms inference, 0.0ms postprocess per image at shape (1, 3, 192, 192)
yolov8-p2.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 27.0ms
Speed: 1.0ms preprocess, 27.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
yolov8-p6.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

WARNING ⚠️ imgsz=[160] must be multiple of max stride 64, updating to [192]
image 1/1 /ultralytics/assets/bus.jpg: 192x192 (no detections), 24.0ms
Speed: 0.0ms preprocess, 24.0ms inference, 1.0ms postprocess per image at shape (1, 3, 192, 192)
yolov8-pose.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 33.0ms
Speed: 1.0ms preprocess, 33.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
yolov8-pose-p2.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 23.0ms
Speed: 1.0ms preprocess, 23.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
yolov8-pose-p6.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

WARNING ⚠️ imgsz=[160] must be multiple of max stride 64, updating to [192]
image 1/1 /ultralytics/assets/bus.jpg: 192x192 (no detections), 17.0ms
Speed: 0.0ms preprocess, 17.0ms inference, 1.0ms postprocess per image at shape (1, 3, 192, 192)
yolov8-rtdetr.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

image 1/1 /ultralytics/assets/bus.jpg: 640x640 (no detections), 48.0ms
Speed: 5.0ms preprocess, 48.0ms inference, 1.0ms postprocess per image at shape (1, 3, 640, 640)
yolov8-seg.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 27.0ms
Speed: 0.0ms preprocess, 27.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
yolov8-seg-p2.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 19.0ms
Speed: 1.0ms preprocess, 19.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
yolov8-seg-p6.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

WARNING ⚠️ imgsz=[160] must be multiple of max stride 64, updating to [192]
image 1/1 /ultralytics/assets/bus.jpg: 192x192 (no detections), 9.0ms
Speed: 1.0ms preprocess, 9.0ms inference, 1.0ms postprocess per image at shape (1, 3, 192, 192)
yolov8-world.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 27.0ms
Speed: 1.0ms preprocess, 27.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
yolov8-worldv2.yaml
WARNING ⚠️ no model scale passed. Assuming scale='n'.

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 13.0ms
Speed: 0.0ms preprocess, 13.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
yolov9c.yaml

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 71.0ms
Speed: 0.0ms preprocess, 71.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
yolov9c-seg.yaml

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 31.0ms
Speed: 1.0ms preprocess, 31.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
yolov9e.yaml

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 56.0ms
Speed: 2.0ms preprocess, 56.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
yolov9e-seg.yaml

image 1/1 /ultralytics/assets/bus.jpg: 160x128 (no detections), 32.0ms
Speed: 0.0ms preprocess, 32.0ms inference, 1.0ms postprocess per image at shape (1, 3, 160, 128)
.                                                                                                                                                                              [100%]

========================================================================================== slowest 30 durations ========================================================================================== 
22.36s call     tests/test_python.py::test_all_model_yamls

(2 durations < 0.005s hidden.  Use -vv to show these durations.)
=========================================================================================== 1 passed in 22.39s ===========================================================================================

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Simplified and reorganized the YOLOv8 model configurations for better clarity and modularity.

📊 Key Changes

  • Unified Model Configurations: Streamlined configurations by creating task-specific model entries (e.g., detect, classify, seg, pose).
  • Suffix & Modifier Handling: Enhanced model naming with suffixes and modifiers to better represent model variants and their functionalities.
  • Enhanced Readability: Improved code structure and comments to make the model configurations easier to understand and modify.

🎯 Purpose & Impact

  • Simplification: Makes it easier for developers to navigate and understand various YOLOv8 model configurations.
  • Modularity: Facilitates the addition of new model types or configurations by following the established modular pattern.
  • Future-proofing: Prepares the configurations for easier updates and expansions, supporting the growth of the Ultralytics YOLO model ecosystem.

@Burhan-Q Burhan-Q added the enhancement New feature or request label Apr 18, 2024
Copy link

codecov bot commented Apr 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.01%. Comparing base (03da294) to head (af9cc82).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10163   +/-   ##
=======================================
  Coverage   75.01%   75.01%           
=======================================
  Files         122      122           
  Lines       15579    15585    +6     
=======================================
+ Hits        11686    11691    +5     
- Misses       3893     3894    +1     
Flag Coverage Δ
Benchmarks 35.59% <10.00%> (-0.01%) ⬇️
GPU 37.37% <20.00%> (-0.01%) ⬇️
Tests 71.16% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Burhan-Q
Copy link
Member Author

Burhan-Q commented Apr 23, 2024

Note

Changes to be made as recommend by @Laughing-q

  • separate YOLOv8 to use multiple YAMLs, but place all tasks under single YAML
  • keep YOLOv8-p2 and YOLOv8-p6 configurations separated, but include all tasks for each
  • other YOLOv8 variants (YOLOv8-ghost, YOLOv8-ghost-p2, YOLOv8-ghost-p6, YOLOv8-rtdetr, YOLOv8-world, YOLOv8-worldv2, YOLOv8-cls-resnet) should all have their own YAML config files
  • planning to combine YOLOv8-cls-resnet YAML configs into a single file

This should result in only having 10 YAML files instead of the 19.

@Burhan-Q
Copy link
Member Author

Combining yolov8-cls-resnet variants of the YAML files was a bit of a hassle, so left separated. Now down to 11 YAML files instead of 17

@Laughing-q
Copy link
Member

@Burhan-Q Hey I attempted to simplify the PR a little bit:

  • Moved SPPF module into neck part so we don't need to split backbone to two parts.
  • Use list in yaml file instead of dict so we don't need to sort the architectures first before actual parsing it.
  • Also reverted the yolov3 part. I think the main idea here is to try to merge yaml files of different tasks into one. We probably should leave these yamls with different architectures for now.

What do you think?

@Burhan-Q
Copy link
Member Author

@Laughing-q Thank you for helping out in this! I definitely like moving SPP to the neck definition, I think that makes a lot of sense. Should we do that with all the models for consistency (I know it probably isn't critical)? Also, I'm wondering about changing the model key definition to:

yolov8: [*backbone,  *neck,  *detect ]

As long as the order is maintained (which I think it should), then the step for removing the old keys could be avoided. I can test this later if you don't get a chance to sooner. I forgot about the YOLOv3 YAML, thank you!

Overall I agree with the improvements, as it should simplify things a lot. Sometimes I'm too close to the problem and I end up failing to see something trivial, which is why I always appreciate your input! 🚀

@Laughing-q
Copy link
Member

@Burhan-Q Yes I actually tried the list format you suggested at first but then I realized that we'll need to update the logic here a little bit since original code take it as a dict:
pic-240427-2243-19
so for backward compatibility I still kept it.
But yeah please go ahead and try some implementations since I still think there's duplicated backbone and neck part(the keys) here, it;'s better we can remove these.
pic-240427-2248-15

@Burhan-Q Burhan-Q marked this pull request as draft May 3, 2024 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants