v3.0 Release (#725)
* initial commit * remove yolov3-spp from test.py study * update study --img range * update mAP * cleanup and speed updates * update README plot
This commit is contained in:
1 parent
1ddf692bf8
commit
916d4aad9a
11 files changed
+43
-40
No files matched your search
@@ -10,12 +10,6 @@ class Swish(nn.Module): #
|
||||
return x * torch.sigmoid(x)
|
||||
|
||||
|
||||
class HardSwish(nn.Module):
|
||||
@staticmethod
|
||||
def forward(x):
|
||||
return x * F.hardtanh(x + 3, 0., 6., True) / 6.
|
||||
|
||||
|
||||
class MemoryEfficientSwish(nn.Module):
|
||||
class F(torch.autograd.Function):
|
||||
@staticmethod
|
||||
|
||||
+2
-2
@@ -610,7 +610,7 @@ def load_mosaic(self, index):
|
||||
|
||||
labels4 = []
|
||||
s = self.img_size
|
||||
yc, xc = s, s # mosaic center x, y
|
||||
yc, xc = [int(random.uniform(-x, 2 * s + x)) for x in self.mosaic_border] # mosaic center x, y
|
||||
indices = [index] + [random.randint(0, len(self.labels) - 1) for _ in range(3)] # 3 additional image indices
|
||||
for i, index in enumerate(indices):
|
||||
# Load image
|
||||
@@ -804,7 +804,7 @@ def random_perspective(img, targets=(), degrees=10, translate=.1, scale=.1, shea
|
||||
return img, targets
|
||||
|
||||
|
||||
def box_candidates(box1, box2, wh_thr=2, ar_thr=20, area_thr=0.2): # box1(4,n), box2(4,n)
|
||||
def box_candidates(box1, box2, wh_thr=2, ar_thr=20, area_thr=0.1): # box1(4,n), box2(4,n)
|
||||
# Compute candidate boxes: box1 before augment, box2 after augment, wh_thr (pixels), aspect_ratio_thr, area_ratio
|
||||
w1, h1 = box1[2] - box1[0], box1[3] - box1[1]
|
||||
w2, h2 = box2[2] - box2[0], box2[3] - box2[1]
|
||||
|
||||
+10
-7
@@ -1147,7 +1147,7 @@ def plot_study_txt(f='study.txt', x=None): # from utils.general import *; plot_
|
||||
ax = ax.ravel()
|
||||
|
||||
fig2, ax2 = plt.subplots(1, 1, figsize=(8, 4), tight_layout=True)
|
||||
for f in ['coco_study/study_coco_yolov5%s.txt' % x for x in ['s', 'm', 'l', 'x']]:
|
||||
for f in ['study/study_coco_yolov5%s.txt' % x for x in ['s', 'm', 'l', 'x']]:
|
||||
y = np.loadtxt(f, dtype=np.float32, usecols=[0, 1, 2, 3, 7, 8, 9], ndmin=2).T
|
||||
x = np.arange(y.shape[1]) if x is None else np.array(x)
|
||||
s = ['P', 'R', 'mAP@.5', 'mAP@.5:.95', 't_inference (ms/img)', 't_NMS (ms/img)', 't_total (ms/img)']
|
||||
@@ -1159,7 +1159,7 @@ def plot_study_txt(f='study.txt', x=None): # from utils.general import *; plot_
|
||||
ax2.plot(y[6, :j], y[3, :j] * 1E2, '.-', linewidth=2, markersize=8,
|
||||
label=Path(f).stem.replace('study_coco_', '').replace('yolo', 'YOLO'))
|
||||
|
||||
ax2.plot(1E3 / np.array([209, 140, 97, 58, 35, 18]), [33.8, 39.6, 43.0, 47.5, 49.4, 50.7],
|
||||
ax2.plot(1E3 / np.array([209, 140, 97, 58, 35, 18]), [34.6, 40.5, 43.0, 47.5, 49.7, 51.5],
|
||||
'k.-', linewidth=2, markersize=8, alpha=.25, label='EfficientDet')
|
||||
|
||||
ax2.grid()
|
||||
@@ -1170,7 +1170,7 @@ def plot_study_txt(f='study.txt', x=None): # from utils.general import *; plot_
|
||||
ax2.set_ylabel('COCO AP val')
|
||||
ax2.legend(loc='lower right')
|
||||
plt.savefig('study_mAP_latency.png', dpi=300)
|
||||
plt.savefig(f.replace('.txt', '.png'), dpi=200)
|
||||
plt.savefig(f.replace('.txt', '.png'), dpi=300)
|
||||
|
||||
|
||||
def plot_labels(labels, save_dir=''):
|
||||
@@ -1247,8 +1247,11 @@ def plot_results(start=0, stop=0, bucket='', id=(), labels=(),
|
||||
s = ['GIoU', 'Objectness', 'Classification', 'Precision', 'Recall',
|
||||
'val GIoU', 'val Objectness', 'val Classification', 'mAP@0.5', 'mAP@0.5:0.95']
|
||||
if bucket:
|
||||
os.system('rm -rf storage.googleapis.com')
|
||||
files = ['https://storage.googleapis.com/%s/results%g.txt' % (bucket, x) for x in id]
|
||||
# os.system('rm -rf storage.googleapis.com')
|
||||
# files = ['https://storage.googleapis.com/%s/results%g.txt' % (bucket, x) for x in id]
|
||||
files = ['results%g.txt' % x for x in id]
|
||||
c = ('gsutil cp ' + '%s ' * len(files) + '.') % tuple('gs://%s/results%g.txt' % (bucket, x) for x in id)
|
||||
os.system(c)
|
||||
else:
|
||||
files = glob.glob(str(Path(save_dir) / 'results*.txt')) + glob.glob('../../Downloads/results*.txt')
|
||||
for fi, f in enumerate(files):
|
||||
@@ -1266,8 +1269,8 @@ def plot_results(start=0, stop=0, bucket='', id=(), labels=(),
|
||||
ax[i].set_title(s[i])
|
||||
# if i in [5, 6, 7]: # share train and val loss y axes
|
||||
# ax[i].get_shared_y_axes().join(ax[i], ax[i - 5])
|
||||
except:
|
||||
print('Warning: Plotting error for %s, skipping file' % f)
|
||||
except Exception as e:
|
||||
print('Warning: Plotting error for %s; %s' % (f, e))
|
||||
|
||||
fig.tight_layout()
|
||||
ax[1].legend()
|
||||
|
||||
Reference in new issue
Block a user