ultralytics / yolov3

YOLOv3 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
10.18k stars 3.44k forks source link

plot results #1299

Closed SteelMinh closed 4 years ago

SteelMinh commented 4 years ago

Hi, How i can plot the results.txt? I try this: from utils import utils; utils.plot_results()

But nothing happen.

larrywal-express commented 4 years ago

A result.txt will be generated at the beginning of your training. Once you run that code, you will see an image named result.png. open it to view your result

SteelMinh commented 4 years ago

Thank you larrywal-express for the quick answer. Sorry it's my fault. I mean how i can plot the results.png? I have the results.txt and now i want to plot the results.png

glenn-jocher commented 4 years ago

https://github.com/ultralytics/yolov3/blob/c4b0f986d195412e3a057aff1be3cb0da7e7d317/utils/utils.py#L1041-L1042

larrywal-express commented 4 years ago

2, 3, 4, 8, 9, 12, 13, 14, 10, 11 G, O, C, P, R, Val G, Val O, Val C, mAP, F1 start count from 0. 0 is x-axis (0 to 299), while others numbers is y-axis. You can open the results.txt with Notepad, copy and paste in Origin or excel and plot.

shin6221 commented 4 years ago

Hi, I also have some issue with this plot program. I got the results.txt file after training. When I run the code from utils import utils; utils.plot_results() I got feedback like this

from utils import utils; utils.plot_results() Traceback (most recent call last): File "", line 1, in File "D:\deep_learning\yolov3-4\utils\utils.py", line 486, in plot_results results = np.loadtxt(f, usecols=[2, 3, 4, 5, 6, 9, 10, 11, 12]).T # column 11 is mAP File "C:\Users\shin\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 1141, in loadtxt for x in read_data(_loadtxt_chunksize): File "C:\Users\shin\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 1061, in read_data vals = [vals[j] for j in usecols] File "C:\Users\shin\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 1061, in vals = [vals[j] for j in usecols] IndexError: list index out of range

I couldn't get any png and I don't know how to solve this issue.

Muxindawang commented 4 years ago

Hi, How i can plot the results.txt? I try this: from utils import utils; utils.plot_results()

But nothing happen.

did you solve this issue?

glenn-jocher commented 4 years ago

@shin6221 @Muxindawang if nothing happens, you have no results.txt to plot.

Muxindawang commented 4 years ago

@shin6221 @Muxindawang if nothing happens, you have no results.txt to pl Thank you, and I have another issue.It is about the version of tensorboard.If I want to use tensorboard but my tensorboard version is 1.11, should I uninstall tensorflow and tensorboard and reinstall them

glenn-jocher commented 4 years ago

@Muxindawang you can use one of our working environments:

Reproduce Our Environment

To access an up-to-date working environment (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled), consider a:

Muxindawang commented 4 years ago

jiang

@Muxindawang you can use one of our working environments:

Reproduce Our Environment

To access an up-to-date working environment (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled), consider a:

* **GCP** Deep Learning VM with $300 free credit offer: See our [GCP Quickstart Guide](https://docs.ultralytics.com/yolov5/environments/google_cloud_quickstart_tutorial/)

* **Google Colab Notebook** with 12 hours of free GPU time. [![Open In Colab](https://camo.githubusercontent.com/52feade06f2fecbf006889a904d221e6a730c194/68747470733a2f2f636f6c61622e72657365617263682e676f6f676c652e636f6d2f6173736574732f636f6c61622d62616467652e737667)](https://colab.research.google.com/github/ultralytics/yolov5/blob/master/tutorial.ipynb)

* **Docker Image** https://hub.docker.com/r/ultralytics/yolov5. See [Docker Quickstart Guide](https://docs.ultralytics.com/yolov5/environments/docker_image_quickstart_tutorial/)

I get it 非常感谢

shin6221 commented 4 years ago

Hi, How i can plot the results.txt? I try this: from utils import utils; utils.plot_results() But nothing happen.

did you solve this issue?

Hi,i solved some part of this issue by revising the code

I forgot to mention my version is V4, a previous version.

the code is at the bottom of utils.py

def plot_results(start=0): # from utils.utils import *; plot_results()

Plot YOLO training results file 'results.txt'

# import os; os.system('wget https://storage.googleapis.com/ultralytics/yolov3/results_v3.txt')

fig = plt.figure(figsize=(14, 7))
s = ['X + Y', 'Width + Height', 'Confidence', 'Classification', 'Total Loss', 'Precision', 'Recall', 'mAP']
for f in sorted(glob.glob('results*.txt')):
    results = np.loadtxt(f, usecols=[2, 3, 4, 5, 6, 9, 10, 11]).T  # column 11 is mAP #previous usecols=[2, 3, 4, 5, 6, 9, 10, 11, 12]
    x = range(start, results.shape[1])
    for i in range(8):
        plt.subplot(2, 4, i + 1)
        plt.plot(x, results[i, x], marker='.', label=f)
        plt.title(s[i])
        if i == 0:
            plt.legend()
        if i == 6:                                                                                                          #previous i== 7
            plt.plot(x, results[i + 1, x], marker='.', label=f)
fig.tight_layout()
fig.savefig('results.jpg', dpi=fig.dpi)

it plots now with some other issue, trying to fix

and i have tried the latest version, YOLOv3 master has no problem with plot.

hope it helps

WANGCHAO1996 commented 4 years ago

A result.txt will be generated at the beginning of your training. Once you run that code, you will see an image named result.png. open it to view your result

Excuse me How to calculate mAP, PR curve and AP of single class according to the result. txt file

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

glenn-jocher commented 11 months ago

@WANGCHAO1996 you can easily calculate mAP, PR curve, and AP for a single class using the precision_recall module in Ultralytics.YOLOv3. You can utilize the following code snippet to locate precision and recall curves for a specific class in the results.txt file:

from utils import utils

path = 'path_to_results_file/results.txt'
data = utils.load_results(path)  
precision, recall, AP, f1, ap_class = utils.get_batch_statistics(data, iou_thres=0.5)

You can replace 'path_to_results_file' with the actual path to the results file on your local machine. The 'ap_class' above refers to the Average Precision (AP) of a single class that you are interested in.