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

Added warning message when --single-cls is used incorrectly by [#13028](https://github.com/ultralytics/yolov5/issues/13028) #13032

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

Le0v1n
Copy link

@Le0v1n Le0v1n commented May 21, 2024

In issue #13028, I raised a question about --single-cls and provided a code suggestion, therefore I am applying for a PR. I only modified the code in train.py, as shown below:

# ---------- Original Code ----------
names = {0: "item"} if single_cls and len(data_dict["names"]) != 1 else data_dict["names"]  # class names


# ---------- Modified Code ----------
if single_cls and len(data_dict["names"]) != 1:
	LOGGER.warning(
		"WARNING ⚠️ Please check the dataset to ensure that when --single-cls is enabled, "
		"the number of classes in the dataset is 1."
	)
	names = {0: "item"}  # combine all classes into a single class
else:
	names = data_dict["names"]  # class names

Here, by setting a warning, we prevent users from mistakenly using the --single-cls parameter during training. This is because when the number of classes in the dataset configuration file is not 1, --single-cls will force the dataset into the form {0: "item"}.

I have tested the code locally with the following shell command:

python train.py --data coco128.yaml --weights yolov5s.pt --img 640 --single-cls

Since the MS COCO dataset has 80 classes, the program normally issued a warning as follows:

image

I'm very happy to submit code to Ultralytics! 🥰

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Enhanced dataset validation and warning for --single-cls mode in training.

📊 Key Changes

  • Added a warning when --single-cls is enabled but the dataset indicates multiple classes.
  • Modified class name handling to provide clearer guidance when --single-cls is used incorrectly.

🎯 Purpose & Impact

  • Ensure clarity: Warns users when their dataset configuration might not match the intended single class training mode, helping to prevent confusion or incorrect model training setups. 🚦
  • Improve usability: By signaling potential misconfigurations early, users can correct dataset issues before proceeding, enhancing the training process's overall smoothness and efficiency. 🛠️
  • Facilitate better outcomes: Aids in ensuring that model training is conducted under the correct assumptions, potentially leading to more accurate models when using the --single-cls flag. 🎯

Copy link
Contributor

github-actions bot commented May 21, 2024

All Contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 Hello @Le0v1n, thank you for submitting a YOLOv5 🚀 PR! To allow your work to be integrated as seamlessly as possible, we advise you to:

  • ✅ Verify your PR is up-to-date with ultralytics/yolov5 master branch. If your PR is behind you can update your code by clicking the 'Update branch' button or by running git pull and git merge master locally.
  • ✅ Verify all YOLOv5 Continuous Integration (CI) checks are passing.
  • ✅ Reduce changes to the absolute minimum required for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

@Le0v1n
Copy link
Author

Le0v1n commented May 21, 2024

I have read the CLA Document and I sign the CLA

@Le0v1n
Copy link
Author

Le0v1n commented May 24, 2024

@glenn-jocher My code passed the initial test, but after Ultralytics made a commit, the following issue occurred during retesting:

Post job cleanup.
"C:\Program Files\Git\usr\bin\tar.exe" --posix -cf cache.tzst --exclude cache.tzst -P -C D:/a/yolov5/yolov5 --files-from manifest.txt --force-local --use-compress-program "zstd -T0"
Warning: Failed to save: Cache service responded with 429 during upload chunk.
D:\a\_actions\actions\setup-python\v5\dist\cache-save\index.js:475
                        throw new Error(`Cache upload failed because file read failed with ${error.message}`);
                        ^

Error: Cache upload failed because file read failed with EBADF: bad file descriptor, read
    at ReadStream.<anonymous> (D:\a\_actions\actions\setup-python\v5\dist\cache-save\index.js:475:31)
    at ReadStream.emit (node:events:514:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at errorOrDestroy (node:internal/streams/destroy:214:7)
    at node:internal/fs/streams:260:9
    at FSReqCallback.wrapper [as oncomplete] (node:fs:666:5)

Node.js v20.8.1

It seems that the test failure was due to a network issue rather than the code I modified. How can I request a retest?

@glenn-jocher
Copy link
Member

Hi there! It looks like the issue you encountered is indeed related to a network or cache service error during the GitHub Actions run, and not directly linked to your code changes. To request a retest, you can simply push an empty commit to your branch or close and reopen the pull request to trigger the GitHub Actions again. Here’s how you can push an empty commit:

git commit --allow-empty -m "Trigger retest"
git push

This should start the CI tests anew. Let us know if you need any more help! 😊

Copy link
Author

@Le0v1n Le0v1n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-CI for PR

@Le0v1n
Copy link
Author

Le0v1n commented May 24, 2024

@glenn-jocher Thank you very much for your reply, I have pushed again. 🥰

@glenn-jocher
Copy link
Member

You're welcome! If you need further assistance, feel free to ask. Happy coding! 😊

@Le0v1n
Copy link
Author

Le0v1n commented Jun 30, 2024

@glenn-jocher

Hello, I am very happy to be able to submit code to Ultralytics. However, this simple piece of code has been submitted for a long time, and I receive email reminders from UltralyticsAssistant every week. After I click the link, it also reminds me "This branch has no conflicts with the base branch". All checks have passed, but it seems that the code has not been merged into the master branch.

What action do I need to take? (please forgive me for being almost a novice in this area)

@glenn-jocher
Copy link
Member

@Le0v1n hello!

Thank you for your contribution and for your patience. We truly appreciate your effort to improve YOLOv5! 😊

It sounds like your pull request is in good shape, especially since all checks have passed and there are no conflicts. Sometimes, the merging process can take a bit of time due to various factors, such as ongoing reviews or other priorities.

Here are a few steps you can take to ensure everything is in order:

  1. Verify the Latest Versions: Ensure that your branch is up-to-date with the latest changes from the master branch. You can do this by pulling the latest changes and merging them into your branch:

    git fetch origin
    git checkout your-branch-name
    git merge origin/master
    git push
  2. Reconfirm the Issue: Double-check that the issue your code addresses is still relevant and reproducible with the latest versions of torch and YOLOv5. This helps maintainers prioritize and validate the necessity of the fix.

  3. Follow Up: If everything looks good and the issue persists, you can politely follow up on the pull request thread to bring it to the maintainers' attention. A friendly reminder can sometimes help expedite the review process.

If you have any further questions or need additional assistance, feel free to ask. We're here to help! Thank you again for your valuable contribution to the YOLOv5 project.

@Le0v1n
Copy link
Author

Le0v1n commented Jul 1, 2024

@glenn-jocher Thank you for your reply, I will just continue to wait. 😊

@glenn-jocher
Copy link
Member

Hi @Le0v1n,

Thank you for your patience and understanding! 😊 We appreciate your enthusiasm and contribution to the YOLOv5 project.

If you have any further questions or need additional assistance while waiting, feel free to reach out here. We're always here to help and ensure that your experience with YOLOv5 is smooth and productive.

Thank you again for your valuable contribution and for being a part of the Ultralytics community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants