-
-
Notifications
You must be signed in to change notification settings - Fork 15.9k
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
Add new --save-csv
argument to detect.py
#12042
Add new --save-csv
argument to detect.py
#12042
Conversation
added support for saving result in csv,used for testing Signed-off-by: Akash A Desai <62583018+akashAD98@users.noreply.github.com>
for more information, see https://pre-commit.ci
Signed-off-by: Akash A Desai <62583018+akashAD98@users.noreply.github.com>
@glenn-jocher @AyushExel can you please review it? |
@akashAD98 hi there! Thank you for your contribution to YOLOv5. Saving detection results in a CSV file is indeed a useful feature for testing and analysis purposes. It's great to see that you have added support for this feature and even provided examples of how it can be used. We appreciate your effort in fixing other related issues as well and for providing the necessary command to run the feature. The ability to save the prediction.csv file inside the exp/ folder will make it more convenient for users to access and analyze the results. Your contribution will definitely benefit the YOLOv5 community and we appreciate your dedication to improving the repository. If you have any further questions or need assistance with anything else, please let us know. Keep up the great work! |
detect.py
Outdated
@@ -229,6 +254,7 @@ def parse_opt(): | |||
parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu') | |||
parser.add_argument('--view-img', action='store_true', help='show results') | |||
parser.add_argument('--save-txt', action='store_true', help='save results to *.txt') | |||
parser.add_argument('--save-in-csv', action='store_true', help='save results in CSV format') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe call this --save-csv ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes ill update it
changed save_in_csv to save_csv Signed-off-by: Akash A Desai <62583018+akashAD98@users.noreply.github.com>
@AyushExel please have look |
@akashAD98 hi there! Thank you for bringing this issue to our attention. We understand the need for saving detection results in a CSV file for further analysis and testing purposes. We appreciate your patience in waiting for a resolution. We will review the feature request and determine the best course of action. Our team is working diligently to address all issues and make improvements to YOLOv5. If you have any additional information or suggestions regarding this feature, please feel free to share them. Your input is valuable to us. Thank you for your support and contribution to YOLOv5. We will keep you updated on the progress. Thank you, |
@glenn-jocher can you please review this pr,seems i did all changes,let me know if anything is missing |
@akashAD98 thank you for your contribution to the YOLOv5 repository. We appreciate your effort in addressing the issue and making the necessary changes. |
@akashAD98 I took a look at this and it looks good! One thing I noticed was that I don't think we need this if statement as the |
For example I think this will do the same: PR def write_to_csv(image_name, prediction, confidence):
data = {'Image Name': image_name, 'Prediction': prediction, 'Confidence': confidence}
if not csv_path.is_file():
with open(csv_path, mode='w', newline='') as f:
writer = csv.DictWriter(f, fieldnames=data.keys())
writer.writeheader()
else:
with open(csv_path, mode='a', newline='') as f:
writer = csv.DictWriter(f, fieldnames=data.keys())
writer.writerow(data) Proposed change def write_to_csv(image_name, prediction, confidence):
data = {'Image Name': image_name, 'Prediction': prediction, 'Confidence': confidence}
is_file = csv_path.is_file()
with open(csv_path, mode='a', newline='') as f:
writer = csv.DictWriter(f, fieldnames=data.keys())
writer.writerow(data) if is_file else writer.writeheader() |
@akashAD98 pinging you about above comments |
Signed-off-by: Akash A Desai <62583018+akashAD98@users.noreply.github.com>
for more information, see https://pre-commit.ci
@glenn-jocher Ohh i missed your message, I updated it,please have look |
Hi @akashAD98, Thank you for updating the pull request. I appreciate your responsiveness. I reviewed the changes, and it looks good now. The simplification you made to the code is indeed an improvement. I will go ahead and merge your pull request. Your contribution will be a valuable addition to the YOLOv5 repository. Keep up the good work! Thanks, |
@glenn-jocher waiting for pr to merge :) |
@akashAD98 thanks for your contribution! I'm glad to see that you've submitted a pull request. Our team will review it as soon as possible. We appreciate your patience in waiting for it to be merged. Keep up the good work! |
--save-csv
argument to detect.py
@akashAD98 I've reviewed and tested the PR, all good, PR merged! Thank you for your contributions to YOLO :) |
@glenn-jocher @AyushExel thanks guys |
@akashAD98 thank you for your kind words! We appreciate your support. If you have any questions or need any assistance, feel free to ask. |
Add new `--save-csv` argument to detect.py (ultralytics#12042)
* Update detect.py added support for saving result in csv,used for testing Signed-off-by: Akash A Desai <62583018+akashAD98@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update detect.py Signed-off-by: Akash A Desai <62583018+akashAD98@users.noreply.github.com> * Update detect.py changed save_in_csv to save_csv Signed-off-by: Akash A Desai <62583018+akashAD98@users.noreply.github.com> * Update detect.py Signed-off-by: Akash A Desai <62583018+akashAD98@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Akash A Desai <62583018+akashAD98@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
feature #12041
added support for saving results in CSV, used for testing purposes
fixed: #9690,
#10189
Another issue and PR but this is for classification: #11654
added argument --save-in-csv ,then only it will save the result in CSV file
why this feature is important?
if we want to do testing of our model,then doing this thing manually is very time take, We can simply get the CSV file & result, then we can add our remark there & get the best confidence score or other analysis using this sheet
example use case:
how to run it?
the prediction.csv file will save inside exp/ folder
🤖 Generated by Copilot at 71114f4
Summary
✨💾📄
This file adds an option to export detection results to a CSV file. It uses a new
save_in_csv
argument and awrite_to_csv
function to handle the CSV output.Walkthrough
--save-in-csv
option) (link, link, link, link)🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Added CSV output support for object detection results in YOLOv5.
📊 Key Changes
detect.py
.save_csv
argument to enable CSV output format.predictions.csv
and appends detection results with image names, predicted classes, and confidence scores.🎯 Purpose & Impact