Skip to content

Commit

Permalink
Update profile_idetection() (#1727)
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher committed Dec 18, 2020
1 parent d5289b5 commit 49abc72
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions utils/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,27 +330,26 @@ def plot_evolution(yaml_file='data/hyp.finetune.yaml'): # from utils.plots impo


def profile_idetection(start=0, stop=0, labels=(), save_dir=''):
# Plot iDetection '*.txt' per-image logs. from . import *; profile_idetection()
fig, ax = plt.subplots(2, 4, figsize=(12, 6), tight_layout=True)
ax = ax.ravel()
# Plot iDetection '*.txt' per-image logs. from utils.plots import *; profile_idetection()
ax = plt.subplots(2, 4, figsize=(12, 6), tight_layout=True)[1].ravel()
s = ['Images', 'Free Storage (GB)', 'RAM Usage (GB)', 'Battery', 'dt_raw (ms)', 'dt_smooth (ms)', 'real-world FPS']
files = list(Path(save_dir).glob('frames*.txt'))
for fi, f in enumerate(files):
try:
results = np.loadtxt(f, ndmin=2).T[:, 90:-30] # clip first and last rows
n = results.shape[1] # number of rows
x = np.arange(start, min(stop, n) if stop else n)
results = results[:, x]
t = (results[0] - results[0].min()) # set t0=0s
results[0] = x
for i, a in enumerate(ax):
if i < len(results):
y = results[i, x]
label = labels[fi] if len(labels) else f.stem.replace('frames_', '')
a.plot(t, y, marker='.', label=label, linewidth=1, markersize=5)
a.plot(t, results[i], marker='.', label=label, linewidth=1, markersize=5)
a.set_title(s[i])
a.set_xlabel('time (s)')
# if fi == len(files) - 1:
# a.set_ylim(bottom=0)
# a.set_ylim(bottom=0)
for side in ['top', 'right']:
a.spines[side].set_visible(False)
else:
Expand All @@ -359,7 +358,7 @@ def profile_idetection(start=0, stop=0, labels=(), save_dir=''):
print('Warning: Plotting error for %s; %s' % (f, e))

ax[1].legend()
fig.savefig(Path(save_dir) / 'idetection_profile.png', dpi=200)
plt.savefig(Path(save_dir) / 'idetection_profile.png', dpi=200)


def plot_results_overlay(start=0, stop=0): # from utils.plots import *; plot_results_overlay()
Expand Down

0 comments on commit 49abc72

Please sign in to comment.