glenn-jocher
commited on
Commit
•
c9798ae
1
Parent(s):
0f2057e
Update plot_study_txt() (#1533)
Browse files- utils/plots.py +5 -6
utils/plots.py
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
# Plotting utils
|
2 |
|
3 |
import glob
|
4 |
-
import math
|
5 |
import os
|
6 |
import random
|
7 |
from copy import copy
|
8 |
from pathlib import Path
|
9 |
|
10 |
import cv2
|
|
|
11 |
import matplotlib
|
12 |
import matplotlib.pyplot as plt
|
13 |
import numpy as np
|
@@ -218,13 +218,13 @@ def plot_targets_txt(): # from utils.plots import *; plot_targets_txt()
|
|
218 |
plt.savefig('targets.jpg', dpi=200)
|
219 |
|
220 |
|
221 |
-
def plot_study_txt(
|
222 |
# Plot study.txt generated by test.py
|
223 |
fig, ax = plt.subplots(2, 4, figsize=(10, 6), tight_layout=True)
|
224 |
ax = ax.ravel()
|
225 |
|
226 |
fig2, ax2 = plt.subplots(1, 1, figsize=(8, 4), tight_layout=True)
|
227 |
-
for f in ['
|
228 |
y = np.loadtxt(f, dtype=np.float32, usecols=[0, 1, 2, 3, 7, 8, 9], ndmin=2).T
|
229 |
x = np.arange(y.shape[1]) if x is None else np.array(x)
|
230 |
s = ['P', 'R', '[email protected]', '[email protected]:.95', 't_inference (ms/img)', 't_NMS (ms/img)', 't_total (ms/img)']
|
@@ -234,7 +234,7 @@ def plot_study_txt(f='study.txt', x=None): # from utils.plots import *; plot_st
|
|
234 |
|
235 |
j = y[3].argmax() + 1
|
236 |
ax2.plot(y[6, :j], y[3, :j] * 1E2, '.-', linewidth=2, markersize=8,
|
237 |
-
label=
|
238 |
|
239 |
ax2.plot(1E3 / np.array([209, 140, 97, 58, 35, 18]), [34.6, 40.5, 43.0, 47.5, 49.7, 51.5],
|
240 |
'k.-', linewidth=2, markersize=8, alpha=.25, label='EfficientDet')
|
@@ -246,8 +246,7 @@ def plot_study_txt(f='study.txt', x=None): # from utils.plots import *; plot_st
|
|
246 |
ax2.set_xlabel('GPU Speed (ms/img)')
|
247 |
ax2.set_ylabel('COCO AP val')
|
248 |
ax2.legend(loc='lower right')
|
249 |
-
plt.savefig('
|
250 |
-
plt.savefig(f.replace('.txt', '.png'), dpi=300)
|
251 |
|
252 |
|
253 |
def plot_labels(labels, save_dir=''):
|
|
|
1 |
# Plotting utils
|
2 |
|
3 |
import glob
|
|
|
4 |
import os
|
5 |
import random
|
6 |
from copy import copy
|
7 |
from pathlib import Path
|
8 |
|
9 |
import cv2
|
10 |
+
import math
|
11 |
import matplotlib
|
12 |
import matplotlib.pyplot as plt
|
13 |
import numpy as np
|
|
|
218 |
plt.savefig('targets.jpg', dpi=200)
|
219 |
|
220 |
|
221 |
+
def plot_study_txt(path='', x=None): # from utils.plots import *; plot_study_txt()
|
222 |
# Plot study.txt generated by test.py
|
223 |
fig, ax = plt.subplots(2, 4, figsize=(10, 6), tight_layout=True)
|
224 |
ax = ax.ravel()
|
225 |
|
226 |
fig2, ax2 = plt.subplots(1, 1, figsize=(8, 4), tight_layout=True)
|
227 |
+
for f in [Path(path) / f'study_coco_{x}.txt' for x in ['yolov5s', 'yolov5m', 'yolov5l', 'yolov5x']]:
|
228 |
y = np.loadtxt(f, dtype=np.float32, usecols=[0, 1, 2, 3, 7, 8, 9], ndmin=2).T
|
229 |
x = np.arange(y.shape[1]) if x is None else np.array(x)
|
230 |
s = ['P', 'R', '[email protected]', '[email protected]:.95', 't_inference (ms/img)', 't_NMS (ms/img)', 't_total (ms/img)']
|
|
|
234 |
|
235 |
j = y[3].argmax() + 1
|
236 |
ax2.plot(y[6, :j], y[3, :j] * 1E2, '.-', linewidth=2, markersize=8,
|
237 |
+
label=f.stem.replace('study_coco_', '').replace('yolo', 'YOLO'))
|
238 |
|
239 |
ax2.plot(1E3 / np.array([209, 140, 97, 58, 35, 18]), [34.6, 40.5, 43.0, 47.5, 49.7, 51.5],
|
240 |
'k.-', linewidth=2, markersize=8, alpha=.25, label='EfficientDet')
|
|
|
246 |
ax2.set_xlabel('GPU Speed (ms/img)')
|
247 |
ax2.set_ylabel('COCO AP val')
|
248 |
ax2.legend(loc='lower right')
|
249 |
+
plt.savefig('test_study.png', dpi=300)
|
|
|
250 |
|
251 |
|
252 |
def plot_labels(labels, save_dir=''):
|