ultralytics / ultralytics

NEW - YOLOv8 🚀 in PyTorch > ONNX > OpenVINO > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
28.12k stars 5.58k forks source link

A question about yolov8-world.yaml #14321

Open CaffeineLiqueur opened 2 months ago

CaffeineLiqueur commented 2 months ago

Search before asking

Question

Thank you for adding YOLO-World to the YOLOv8 project. Here I have a little question about yolov8-world.yaml, I hope you can help me to answer it. The contents of yolov8-world.yaml are as follows:

# Ultralytics YOLO 🚀, AGPL-3.0 license
# YOLOv8-World object detection model with P3-P5 outputs. For details see https://docs.ultralytics.com/tasks/detect

# Parameters
nc: 80 # number of classes
scales: # model compound scaling constants, i.e. 'model=yolov8n.yaml' will call yolov8.yaml with scale 'n'
  # [depth, width, max_channels]
  n: [0.33, 0.25, 1024] # YOLOv8n summary: 225 layers,  3157200 parameters,  3157184 gradients,   8.9 GFLOPs
  s: [0.33, 0.50, 1024] # YOLOv8s summary: 225 layers, 11166560 parameters, 11166544 gradients,  28.8 GFLOPs
  m: [0.67, 0.75, 768] # YOLOv8m summary: 295 layers, 25902640 parameters, 25902624 gradients,  79.3 GFLOPs
  l: [1.00, 1.00, 512] # YOLOv8l summary: 365 layers, 43691520 parameters, 43691504 gradients, 165.7 GFLOPs
  x: [1.00, 1.25, 512] # YOLOv8x summary: 365 layers, 68229648 parameters, 68229632 gradients, 258.5 GFLOPs

# YOLOv8.0n backbone
backbone:
  # [from, repeats, module, args]
  - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
  - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
  - [-1, 3, C2f, [128, True]]
  - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
  - [-1, 6, C2f, [256, True]]
  - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
  - [-1, 6, C2f, [512, True]]
  - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32
  - [-1, 3, C2f, [1024, True]]
  - [-1, 1, SPPF, [1024, 5]] # 9

# YOLOv8.0n head
head:
  - [-1, 1, nn.Upsample, [None, 2, "nearest"]]
  - [[-1, 6], 1, Concat, [1]] # cat backbone P4
  - [-1, 3, C2fAttn, [512, 256, 8]] # 12

  - [-1, 1, nn.Upsample, [None, 2, "nearest"]]
  - [[-1, 4], 1, Concat, [1]] # cat backbone P3
  - [-1, 3, C2fAttn, [256, 128, 4]] # 15 (P3/8-small)

  - [[15, 12, 9], 1, ImagePoolingAttn, [256]] # 16 (P3/8-small)

  - [15, 1, Conv, [256, 3, 2]]
  - [[-1, 12], 1, Concat, [1]] # cat head P4
  - [-1, 3, C2fAttn, [512, 256, 8]] # 19 (P4/16-medium)

  - [-1, 1, Conv, [512, 3, 2]]
  - [[-1, 9], 1, Concat, [1]] # cat head P5
  - [-1, 3, C2fAttn, [1024, 512, 16]] # 22 (P5/32-large)

  - [[15, 19, 22], 1, WorldDetect, [nc, 512, False]] # Detect(P3, P4, P5)

In line 38, the ImagePoolingAttn module is used as layer 16, but I don't seem to see any use of layer 16 in the rest of the content. So I don't know how the ImagePoolingAttn module works. Looking forward to reply!

Additional

No response

github-actions[bot] commented 2 months ago

👋 Hello @CaffeineLiqueur, thank you for your interest in Ultralytics YOLOv8 🚀! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.

If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.

Install

Pip install the ultralytics package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.

pip install ultralytics

Environments

YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

Ultralytics CI

If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 2 months ago

Hello!

Thank you for your interest in YOLO-World and for bringing up this insightful question about the yolov8-world.yaml configuration.

The ImagePoolingAttn module at layer 16 is indeed an interesting component. While it may not be explicitly referenced in subsequent layers within the provided YAML snippet, it plays a crucial role in enhancing the feature representations by pooling and attending to the spatial features. This helps in capturing more contextual information, which is beneficial for object detection tasks.

To understand its impact, you might want to look into the implementation details of the ImagePoolingAttn module within the Ultralytics codebase. This module typically enhances the feature maps by pooling operations and attention mechanisms, which can improve the model's ability to detect objects in various contexts.

If you have any further questions or need more detailed explanations, feel free to ask. Additionally, if you encounter any issues or bugs, providing a minimum reproducible example can greatly help in diagnosing and resolving the problem. You can find more information on creating such examples here.

Lastly, please ensure you are using the latest version of the Ultralytics packages to benefit from the latest features and fixes.

Happy experimenting with YOLO-World! 🚀

Y-T-G commented 2 months ago

It's used to get txt_feats

https://github.com/ultralytics/ultralytics/blob/997f2c92cd2986137746eb0a70848586354d71bc/ultralytics/nn/tasks.py#L653

Which is used with other layers

CaffeineLiqueur commented 2 months ago

@glenn-jocher @Y-T-G Thank you for taking the time to answer my questions! This helped me a lot! I will try to study the code and continue to learn!

glenn-jocher commented 1 month ago

@CaffeineLiqueur you're very welcome! 😊 I'm glad to hear that the information was helpful to you. Diving into the code is a great way to deepen your understanding, and exploring how the ImagePoolingAttn module contributes to generating txt_feats will certainly be insightful.

If you have any more questions or need further clarification as you study the code, feel free to reach out. The YOLO community and the Ultralytics team are always here to support your learning journey. Happy coding and best of luck with your experiments! 🚀

github-actions[bot] commented 4 weeks ago

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO 🚀 and Vision AI ⭐