Unverified 提交 69ea70cd authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Add idetection_profile() function to plots.py (#1700)

上级 e92245a3
# Plotting utils # Plotting utils
import glob import glob
import math
import os import os
import random import random
from copy import copy from copy import copy
from pathlib import Path from pathlib import Path
import cv2 import cv2
import math
import matplotlib import matplotlib
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
...@@ -329,6 +329,39 @@ def plot_evolution(yaml_file='data/hyp.finetune.yaml'): # from utils.plots impo ...@@ -329,6 +329,39 @@ def plot_evolution(yaml_file='data/hyp.finetune.yaml'): # from utils.plots impo
print('\nPlot saved as evolve.png') print('\nPlot saved as evolve.png')
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()
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)
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.set_title(s[i])
a.set_xlabel('time (s)')
# if fi == len(files) - 1:
# a.set_ylim(bottom=0)
for side in ['top', 'right']:
a.spines[side].set_visible(False)
else:
a.remove()
except Exception as e:
print('Warning: Plotting error for %s; %s' % (f, e))
ax[1].legend()
fig.savefig(Path(save_dir) / 'idetection_profile.png', dpi=200)
def plot_results_overlay(start=0, stop=0): # from utils.plots import *; plot_results_overlay() def plot_results_overlay(start=0, stop=0): # from utils.plots import *; plot_results_overlay()
# Plot training 'results*.txt', overlaying train and val losses # Plot training 'results*.txt', overlaying train and val losses
s = ['train', 'train', 'train', 'Precision', 'mAP@0.5', 'val', 'val', 'val', 'Recall', 'mAP@0.5:0.95'] # legends s = ['train', 'train', 'train', 'Precision', 'mAP@0.5', 'val', 'val', 'val', 'Recall', 'mAP@0.5:0.95'] # legends
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论