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

There seems to be an error in the calculation of the fitness function. #13424

Closed
1 of 2 tasks
thgpddl opened this issue Nov 21, 2024 · 2 comments
Closed
1 of 2 tasks

There seems to be an error in the calculation of the fitness function. #13424

thgpddl opened this issue Nov 21, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@thgpddl
Copy link

thgpddl commented Nov 21, 2024

Search before asking

  • I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

Training

Bug

# utils/metrics.py
def fitness(x):
    # Model fitness as a weighted combination of metrics
    w = [0.0, 0.0, 0.1, 0.9]  # weights for [P, R, [email protected], [email protected]:0.95]
    P=x[0][0]
    R=x[0][1]
    map50=x[0][2]
    map5095=x[0][12]
    return (np.array([[P,R,map50,map5095]])*w).sum(1)

The fitness function in utils/metrics.py determines if it is the best checkpoint by calculating the weighted sum of the four metrics, but the code seems to have x[:, :4] standing for [P, R, [email protected],[email protected]] instead of the expected [P, R, [email protected],[email protected]:0.95]

Environment

None

Minimal Reproducible Example

None

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@thgpddl thgpddl added the bug Something isn't working label Nov 21, 2024
@UltralyticsAssistant
Copy link
Member

👋 Hello @thgpddl, thank you for your interest in YOLOv5 🚀!

It looks like you've come across a potential issue with the fitness function in the training component. If this is indeed a 🐛 Bug Report, could you please provide a minimum reproducible example? This will be incredibly helpful for us to diagnose and address the issue effectively.

An Ultralytics engineer will review your issue soon and provide further assistance. In the meantime, make sure you've followed all the recommended steps in the installation guide, and that your environment meets the minimum requirements with Python, PyTorch, and any other dependencies correctly installed.

YOLOv5 is designed to run in various environments like Notebooks with free GPU, Google Cloud, Amazon Deep Learning AMIs, and Docker. Ensure your current setup aligns with one of these configurations to prevent environment-specific issues.

Thank you for your patience and for helping us improve YOLOv5! 😊

@pderrenger
Copy link
Member

Thank you for pointing this out. The fitness function should indeed calculate the weighted sum of the metrics as [P, R, mAP @thgpddl.5, [email protected]:0.95], with the weights specified as [0.0, 0.0, 0.1, 0.9]. Ensure that your indexing for these metrics is correct. If you are still encountering issues, please verify that you are using the latest version of YOLOv5 from the repository. If the problem persists, feel free to submit a pull request with your proposed fix.

@thgpddl thgpddl closed this as completed Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants