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

predict/classify.py: save all predictions to csv #11654

Closed
wants to merge 6 commits into from

Conversation

sohang3112
Copy link

@sohang3112 sohang3112 commented Jun 4, 2023

Fixes Issue 11482: In classify/predict.py, save all image predictions as CSV for easy analysis later on.

Predictions are saved in predictions.csv in save_dir folder (which is of the form runs/predict-cls/exp-{NUMBER}). Each row in the CSV has results for 1 image.

An example CSV is:

path label confidence top_5_predicted
/path/to/folder/image1.jpg label2 0.75 [["label2", 0.7536121606826782], ["label1", 0.24638774991035461]]
/path/to/folder/image2.jpg label1 0.92 [["label1", 0.9166229963302612], ["label2", 0.08337699621915817]]
/path/to/folder/image3.jpg label1 0.83 [["label1", 0.8311768174171448], ["label2", 0.1688232123851776]]

Here:

  • path is path of image
  • top_5_predicted is a JSON list. Each item is a list of the form [label, score].
  • label, confidence are the predicted label & confidence (i.e., the prediction with maximum score).

πŸ€– Generated by Copilot at fc3be9e

Summary

βœ¨πŸ“·πŸ“„

This pull request adds a new feature to the classify module that allows saving image classification results to a CSV file. The file classify/predict.py is modified to create and write the CSV file in the save_dir folder. The CSV file contains the input file name, the predicted class name and confidence, and the top 5 predicted classes and confidences as a JSON array.

We face the doom of endless data
We need to classify and save
The CSV file holds our fate
The top 5 predictions seal our grave

Walkthrough

  • Save predictions to CSV file in classify module (link, link)

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

πŸ“Š Key Changes

  • The script now includes importing csv, io, and json modules.
  • Experimental loop now runs within a CSV file writing context.
  • Results of the classification (predicted labels and probabilities) are saved in a new CSV file named predictions.csv.

🎯 Purpose & Impact

  • This update allows users to easily export and review all model predictions in a structured and widely-accepted format (CSV).
  • Users can gain insights into model performance and analyze predictions in bulk, which is helpful for reports, audits, or further processing.

🌟 Summary

Predictions from YOLOv5's classification are now automatically saved to a CSV file for easy analysis and sharing. πŸ“πŸ—ƒοΈβœ…

Sohang Chopra added 2 commits June 4, 2023 09:25
Previously was being stored as Python list
(eg. with single quotes strings)
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 @sohang3112, 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

@sohang3112
Copy link
Author

@glenn-jocher Please review this pull request, and let me know if something needs to be improved. Thanks in advance πŸ™‚

@glenn-jocher
Copy link
Member

@sohang3112 thanks for your contribution and submitting the pull request! We appreciate your effort in adding the feature to save image classification results to a CSV file. Our team will review the changes and provide feedback on any improvements that may be needed. Keep up the good work! πŸ‘

@sohang3112
Copy link
Author

@glenn-jocher Did you have a chance to review this PR yet?

@glenn-jocher
Copy link
Member

@sohang3112 thank you for your patience! I apologize for the delay. Our team has been actively reviewing all received pull requests, including yours. We will provide feedback and insights as soon as possible. Your contribution is highly appreciated!

Copy link
Contributor

πŸ‘‹ Hello there! We wanted to let you know that we've decided to close this pull request due to inactivity. We appreciate the effort you put into contributing to our project, but unfortunately, not all contributions are suitable or aligned with our product roadmap.

We hope you understand our decision, and please don't let it discourage you from contributing to open source projects in the future. We value all of our community members and their contributions, and we encourage you to keep exploring new projects and ways to get involved.

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

Thank you for your contributions to YOLO πŸš€ and Vision AI ⭐

@github-actions github-actions bot added the Stale label Apr 18, 2024
@sohang3112
Copy link
Author

@glenn-jocher What sort of behaviour is this from your side?? The PR has been open for many months now, and throughout all that time you didn't find the time to even look at the changes once (let alone review & merge) ?? The only comments from you have been these useless bullshit platitudes of "valuable contribution". In the same time, you found the time to merge many other PRs in this repo, but you didn't even have the time to check the code change in my PR even once??

I have had enough - I'll make sure to never again contribute to any yolo project or any project maintained by you. Bye πŸ‘Ž

@sohang3112 sohang3112 closed this Apr 18, 2024
@glenn-jocher
Copy link
Member

I'm genuinely sorry to hear about your experience and completely understand your frustration. It's our aim to review all contributions with the attention they deserve, but unfortunately, we can sometimes fall short due to the volume of activity. Your time and effort in contributing is truly valued, and I apologize for any oversight. Your feedback is a critical reminder for us to improve our responsiveness and engagement with contributors. Thank you for your past contributions, and I'm truly sorry to see you go. Wishing you the best in your future endeavors.

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

Successfully merging this pull request may close these issues.

classify/predict.py should have an option to save results as CSV
2 participants