glenn-jocher
commited on
Commit
•
49abc72
1
Parent(s):
d5289b5
Update profile_idetection() (#1727)
Browse files- utils/plots.py +6 -7
utils/plots.py
CHANGED
@@ -330,9 +330,8 @@ def plot_evolution(yaml_file='data/hyp.finetune.yaml'): # from utils.plots impo
|
|
330 |
|
331 |
|
332 |
def profile_idetection(start=0, stop=0, labels=(), save_dir=''):
|
333 |
-
# Plot iDetection '*.txt' per-image logs. from . import *; profile_idetection()
|
334 |
-
|
335 |
-
ax = ax.ravel()
|
336 |
s = ['Images', 'Free Storage (GB)', 'RAM Usage (GB)', 'Battery', 'dt_raw (ms)', 'dt_smooth (ms)', 'real-world FPS']
|
337 |
files = list(Path(save_dir).glob('frames*.txt'))
|
338 |
for fi, f in enumerate(files):
|
@@ -340,17 +339,17 @@ def profile_idetection(start=0, stop=0, labels=(), save_dir=''):
|
|
340 |
results = np.loadtxt(f, ndmin=2).T[:, 90:-30] # clip first and last rows
|
341 |
n = results.shape[1] # number of rows
|
342 |
x = np.arange(start, min(stop, n) if stop else n)
|
|
|
343 |
t = (results[0] - results[0].min()) # set t0=0s
|
344 |
results[0] = x
|
345 |
for i, a in enumerate(ax):
|
346 |
if i < len(results):
|
347 |
-
y = results[i, x]
|
348 |
label = labels[fi] if len(labels) else f.stem.replace('frames_', '')
|
349 |
-
a.plot(t,
|
350 |
a.set_title(s[i])
|
351 |
a.set_xlabel('time (s)')
|
352 |
# if fi == len(files) - 1:
|
353 |
-
#
|
354 |
for side in ['top', 'right']:
|
355 |
a.spines[side].set_visible(False)
|
356 |
else:
|
@@ -359,7 +358,7 @@ def profile_idetection(start=0, stop=0, labels=(), save_dir=''):
|
|
359 |
print('Warning: Plotting error for %s; %s' % (f, e))
|
360 |
|
361 |
ax[1].legend()
|
362 |
-
|
363 |
|
364 |
|
365 |
def plot_results_overlay(start=0, stop=0): # from utils.plots import *; plot_results_overlay()
|
|
|
330 |
|
331 |
|
332 |
def profile_idetection(start=0, stop=0, labels=(), save_dir=''):
|
333 |
+
# Plot iDetection '*.txt' per-image logs. from utils.plots import *; profile_idetection()
|
334 |
+
ax = plt.subplots(2, 4, figsize=(12, 6), tight_layout=True)[1].ravel()
|
|
|
335 |
s = ['Images', 'Free Storage (GB)', 'RAM Usage (GB)', 'Battery', 'dt_raw (ms)', 'dt_smooth (ms)', 'real-world FPS']
|
336 |
files = list(Path(save_dir).glob('frames*.txt'))
|
337 |
for fi, f in enumerate(files):
|
|
|
339 |
results = np.loadtxt(f, ndmin=2).T[:, 90:-30] # clip first and last rows
|
340 |
n = results.shape[1] # number of rows
|
341 |
x = np.arange(start, min(stop, n) if stop else n)
|
342 |
+
results = results[:, x]
|
343 |
t = (results[0] - results[0].min()) # set t0=0s
|
344 |
results[0] = x
|
345 |
for i, a in enumerate(ax):
|
346 |
if i < len(results):
|
|
|
347 |
label = labels[fi] if len(labels) else f.stem.replace('frames_', '')
|
348 |
+
a.plot(t, results[i], marker='.', label=label, linewidth=1, markersize=5)
|
349 |
a.set_title(s[i])
|
350 |
a.set_xlabel('time (s)')
|
351 |
# if fi == len(files) - 1:
|
352 |
+
# a.set_ylim(bottom=0)
|
353 |
for side in ['top', 'right']:
|
354 |
a.spines[side].set_visible(False)
|
355 |
else:
|
|
|
358 |
print('Warning: Plotting error for %s; %s' % (f, e))
|
359 |
|
360 |
ax[1].legend()
|
361 |
+
plt.savefig(Path(save_dir) / 'idetection_profile.png', dpi=200)
|
362 |
|
363 |
|
364 |
def plot_results_overlay(start=0, stop=0): # from utils.plots import *; plot_results_overlay()
|