-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
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
Use of tensorboard in yolo.py #2898
Comments
👋 Hello @leotongxue, thank you for your interest in 🚀 YOLOv5! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution. If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you. If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available. For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com. RequirementsPython 3.8 or later with all requirements.txt dependencies installed, including $ pip install -r requirements.txt EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit. |
@leotongxue I'm sorry I don't know what you mean by 'uncomment tensorboard'. Tensorboard is enabled by default for all training runs, you don't need to uncomment anything or modify the code in any way. See the YOLOv5 Colab Notebook training section for an example of how to use TensorBoard: |
@leotongxue you can produce a Tensorboard model graph visual by uncommenting L333 and L335 in train.py. |
@leotongxue sorry, we generally don't help debug custom code, but you can use train.py to get started, as it works correctly there! |
This code is not written by me, this code is in yolo.py😂 |
@leotongxue oh! Ok then I will take a look. Let's see |
@leotongxue I took a look but could not get Tensorboard to cooperate. I'm not sure why it works in train.py and not in yolo.py :( |
Hey, if I run this will that give me the latency of each layer? Just by running the yolo.py? |
@jaskiratsingh2000 in yolo.py first uncomment this line: Line 41 in 1849916
then you can uncomment these lines and run the model with profile=True for a layer by layer profile result Lines 268 to 271 in 1849916
|
@jaskiratsingh2000 I just updated yolo.py for improved profiling output in PR #2940. Output when running yolo.py in profiling mode (above 2 changes) should look like this: YOLOv5 🚀 v5.0-39-g1849916 torch 1.8.1+cu101 CUDA:0 (Tesla P100-PCIE-16GB, 16280.875MB)
from n params module arguments
0 -1 1 3520 models.common.Focus [3, 32, 3]
1 -1 1 18560 models.common.Conv [32, 64, 3, 2]
2 -1 1 18816 models.common.C3 [64, 64, 1]
3 -1 1 73984 models.common.Conv [64, 128, 3, 2]
4 -1 1 156928 models.common.C3 [128, 128, 3]
5 -1 1 295424 models.common.Conv [128, 256, 3, 2]
6 -1 1 625152 models.common.C3 [256, 256, 3]
7 -1 1 1180672 models.common.Conv [256, 512, 3, 2]
8 -1 1 656896 models.common.SPP [512, 512, [5, 9, 13]]
9 -1 1 1182720 models.common.C3 [512, 512, 1, False]
10 -1 1 131584 models.common.Conv [512, 256, 1, 1]
11 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
12 [-1, 6] 1 0 models.common.Concat [1]
13 -1 1 361984 models.common.C3 [512, 256, 1, False]
14 -1 1 33024 models.common.Conv [256, 128, 1, 1]
15 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
16 [-1, 4] 1 0 models.common.Concat [1]
17 -1 1 90880 models.common.C3 [256, 128, 1, False]
18 -1 1 147712 models.common.Conv [128, 128, 3, 2]
19 [-1, 14] 1 0 models.common.Concat [1]
20 -1 1 296448 models.common.C3 [256, 256, 1, False]
21 -1 1 590336 models.common.Conv [256, 256, 3, 2]
22 [-1, 10] 1 0 models.common.Concat [1]
23 -1 1 1182720 models.common.C3 [512, 512, 1, False]
24 [17, 20, 23] 1 229245 Detect [80, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [128, 256, 512]]
Model Summary: 283 layers, 7276605 parameters, 7276605 gradients, 17.1 GFLOPS
time (ms) GFLOPS params module
0.93 1.44 3520 models.common.Focus
0.52 1.90 18560 models.common.Conv
1.31 1.93 18816 models.common.C3
0.38 1.89 73984 models.common.Conv
1.58 4.02 156928 models.common.C3
0.37 1.89 295424 models.common.Conv
1.48 4.00 625152 models.common.C3
0.51 1.89 1180672 models.common.Conv
0.79 1.05 656896 models.common.SPP
0.98 1.89 1182720 models.common.C3
0.18 0.21 131584 models.common.Conv
0.03 0.00 0 torch.nn.modules.upsampling.Upsample
0.05 0.00 0 models.common.Concat
0.87 2.32 361984 models.common.C3
0.16 0.21 33024 models.common.Conv
0.05 0.00 0 torch.nn.modules.upsampling.Upsample
0.09 0.00 0 models.common.Concat
0.81 2.33 90880 models.common.C3
0.35 0.95 147712 models.common.Conv
0.03 0.00 0 models.common.Concat
0.80 1.90 296448 models.common.C3
0.35 0.94 590336 models.common.Conv
0.03 0.00 0 models.common.Concat
1.04 1.89 1182720 models.common.C3
0.69 1.47 229245 Detect
14.4 ms total |
Hey, @glenn-jocher I am still getting the following error when I run what you stated above.
Here is the Google Collab on which I ran this https://colab.research.google.com/drive/1-h9snr0Tu5BJj2lNpbbRRl7HHpxrcf1z?usp=sharing I ran these following commands in the Google Colab step by step to view layers @glenn-jocher Step-1: Cloning the forked repository with that thing uncomment Step-2: Installing dependencies: Step-3: Changing the project file in Google Colab Step-4: Changing the directory in which "yolo.py" file is kept because we want to run this. Step-5: Finally running the "yolo.py" for layer by layer checking. (I have uncommented the " Please let me know @glenn-jocher what step I missed or where I need to make changes. I would really be grateful for your response. Thanks |
@glenn-jocher Also another thing do I need to run this "yolo.py" directly or I need to run the "detect.py" first before all these. Please let me know. Thanks |
@jaskiratsingh2000 the standard yolo.py use case is:
I was not able to run it from within the models/ directory as you mentioned, so to increase robustness to these additional use-cases I've updated yolo.py and export.py in PR #2949. Once this PR is merged you should be able to additionally run yolo.py directly from anywhere in the repo (including within yolov5/models/). |
@glenn-jocher good to hear that it can be run directly but in the meanwhile can you just let me know exactly how can I run it? Do let me know. Thanks |
@jaskiratsingh2000 the standard yolo.py use-case is: cd yolov5
python models/yolo.py |
@glenn-jocher I just checked that as you mentioned above that once this PR will get merged then I would be able to run it directly from anywhere. So, @glenn-jocher Can you let me know exactly that whether it is a bug or I am missing something? You can also refer to my Google Colab above. |
@jaskiratsingh2000 good news 😃! Your original issue may now been fixed ✅ in PR #2949. To receive this update you can:
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 🚀! https://colab.research.google.com/github/ultralytics/yolov5/blob/master/tutorial.ipynb?hl=en |
Thank you so much @glenn-jocher for doing this I am able to run with the use case. Now my another question for which I am encountering an error is that I only see the results of the parameters like this not the time frame of the layers:
Now as you mentioned above that in order to know the profiler I need to run the command here #2898 (comment) I am unable to do run the model. I just wrote the following command in order to produce the time(latency) for every layer:
The error I get after running the above is:
I am not able to produce this. Can you exactly let me know that what steps and commands I have to follow in order to produce the output that you produced above for the latency? Here is my Collab - https://colab.research.google.com/drive/1sVlave0MwcmDJIhBcKnwn9CZEkEa8ZZR?usp=sharing |
@glenn-jocher Can you please let me know on above? |
@jaskiratsingh2000 do not post duplicate questions. This question has already been answered in #2898 (comment) |
@jaskiratsingh2000 please see #2951 (comment) |
❔Question
When I uncomment Tensorboard,the following error occurred
Additional context
Run 'tensorboard --logdir=models/runs' to view tensorboard at http://localhost:6006/
Traceback (most recent call last):
File "/Users/leo/Desktop/yolov5/models/yolo.py", line 279, in
tb_writer.add_graph(model.model, img) # add model to tensorboard
File "/Users/leo/.virtualenvs/yolov5_3/lib/python3.7/site-packages/torch/utils/tensorboard/writer.py", line 724, in add_graph
self._get_file_writer().add_graph(graph(model, input_to_model, verbose))
File "/Users/leo/.virtualenvs/yolov5_3/lib/python3.7/site-packages/torch/utils/tensorboard/_pytorch_graph.py", line 286, in graph
trace = torch.jit.trace(model, args)
File "/Users/leo/.virtualenvs/yolov5_3/lib/python3.7/site-packages/torch/jit/_trace.py", line 742, in trace
_module_class,
File "/Users/leo/.virtualenvs/yolov5_3/lib/python3.7/site-packages/torch/jit/_trace.py", line 940, in trace_module
_force_outplace,
File "/Users/leo/.virtualenvs/yolov5_3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 725, in _call_impl
result = self._slow_forward(*input, **kwargs)
File "/Users/leo/.virtualenvs/yolov5_3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 709, in _slow_forward
result = self.forward(*input, **kwargs)
File "/Users/leo/.virtualenvs/yolov5_3/lib/python3.7/site-packages/torch/nn/modules/container.py", line 117, in forward
input = module(input)
File "/Users/leo/.virtualenvs/yolov5_3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 725, in _call_impl
result = self._slow_forward(*input, **kwargs)
File "/Users/leo/.virtualenvs/yolov5_3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 709, in _slow_forward
result = self.forward(*input, **kwargs)
File "/Users/leo/Desktop/yolov5/models/common.py", line 210, in forward
return torch.cat(x, self.d)
TypeError: cat() received an invalid combination of arguments - got (Tensor, int), but expected one of:
The text was updated successfully, but these errors were encountered: