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

how to draw percision, recall curve for yolov5 tensorboard #4232

Closed
besbesmany opened this issue Jul 30, 2021 · 15 comments
Closed

how to draw percision, recall curve for yolov5 tensorboard #4232

besbesmany opened this issue Jul 30, 2021 · 15 comments
Labels
question Further information is requested Stale

Comments

@besbesmany
Copy link

how to draw the pr_curve for yolov5 tensorboard?

@besbesmany besbesmany added the question Further information is requested label Jul 30, 2021
@glenn-jocher
Copy link
Member

@besbesmany PR curve is saved as PR_curve.png in your logging directory.

@besbesmany
Copy link
Author

I want to compare PR curves for several runs in same chart in tensorboard, how can I do it sir

@glenn-jocher
Copy link
Member

glenn-jocher commented Jul 30, 2021

@besbesmany hi, thank you for your feature suggestion on how to improve YOLOv5 🚀! You'd have to submit a PR for TensorBoard logging of the 4 curves produced: P, R, PR, F1. These four curves are produced here:

yolov5/utils/metrics.py

Lines 69 to 76 in d8f1883

# Compute F1 (harmonic mean of precision and recall)
f1 = 2 * p * r / (p + r + 1e-16)
if plot:
plot_pr_curve(px, py, ap, Path(save_dir) / 'PR_curve.png', names)
plot_mc_curve(px, f1, Path(save_dir) / 'F1_curve.png', names, ylabel='F1')
plot_mc_curve(px, p, Path(save_dir) / 'P_curve.png', names, ylabel='Precision')
plot_mc_curve(px, r, Path(save_dir) / 'R_curve.png', names, ylabel='Recall')

The fastest and easiest way to incorporate your ideas into the official codebase is to submit a Pull Request (PR) implementing your idea, and if applicable providing before and after profiling/inference/training results to help us understand the improvement your feature provides. This allows us to directly see the changes in the code and to understand how they affect workflows and performance.

Please see our ✅ Contributing Guide to get started.

@besbesmany
Copy link
Author

I don't know how to do it , I need help to draw pr curve for several runs in one chart for comparison

@glenn-jocher
Copy link
Member

@besbesmany I looked into this some more, the curves won't plot as scalars in TensorBoard but they are saveable as images:
https://www.tensorflow.org/tensorboard/image_summaries?hl=en

@besbesmany
Copy link
Author

ok thank you sir

@glenn-jocher
Copy link
Member

@besbesmany I would use W&B to view your results, as you can view all your PR curves in a project side by side.

@glenn-jocher
Copy link
Member

@besbesmany good news 😃! Your original issue may now be fixed ✅ in PR #4220. This PR implements callbacks and also adds all results plots to TensorBoard by default. This allows you to compare curves from different runs side by side, i.e.:

Screenshot 2021-08-01 at 00 17 53

To receive this update:

  • Gitgit pull from within your yolov5/ directory or git clone https://github.com/ultralytics/yolov5 again
  • PyTorch Hub – Force-reload with model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
  • Notebooks – View updated notebooks Open In Colab Open In Kaggle
  • Dockersudo docker pull ultralytics/yolov5:latest to update your image Docker Pulls

Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀!

@besbesmany
Copy link
Author

Dear sir
which lines exactly should I run

!git clone https://github.com/ultralytics/yolov5  # clone repo
%pip install -qr requirements.txt  # install dependencies

import torch
from IPython.display import Image, clear_output  # to display images
clear_output()
print(f"Setup complete. Using torch {torch.__version__} ({torch.cuda.get_device_properties(0).name if torch.cuda.is_available() else 'CPU'})")

%load_ext tensorboard
%tensorboard --logdir runs/train

# Train YOLOv5s on COCO128 for 3 epochs
!python train.py --img 640 --batch 16 --epochs 3 --data coco128.yaml --weights yolov5s.pt --cache

should I do anything else to compare pr curve for several runs?

I didn't understand these 2 lines:
PyTorch Hub – Force-reload with model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
Docker – sudo docker pull ultralytics/yolov5:latest to update your image

@glenn-jocher
Copy link
Member

@besbesmany open Colab notebook:
https://colab.research.google.com/github/ultralytics/yolov5/blob/master/tutorial.ipynb

  1. Run Setup cell
  2. Run Tensorboard cell
  3. Run Train cell

@besbesmany
Copy link
Author

Thank you sir

@besbesmany
Copy link
Author

is this also for wandb or tensorboard only?

@glenn-jocher
Copy link
Member

@besbesmany both

@besbesmany
Copy link
Author

thanks alot

@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2021

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 🚀 resources:

Access additional Ultralytics ⚡ resources:

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 YOLOv5 🚀 and Vision AI ⭐!

@github-actions github-actions bot added the Stale label Sep 1, 2021
@github-actions github-actions bot closed this as completed Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

2 participants