Add save_dir to plot_lr_scheduler and plot_labels
Browse files- data/coco128.yaml +2 -2
- train.py +1 -1
- utils/utils.py +3 -3
data/coco128.yaml
CHANGED
@@ -8,8 +8,8 @@
|
|
8 |
|
9 |
|
10 |
# train and val datasets (image directory or *.txt file with image paths)
|
11 |
-
train:
|
12 |
-
val:
|
13 |
|
14 |
# number of classes
|
15 |
nc: 80
|
|
|
8 |
|
9 |
|
10 |
# train and val datasets (image directory or *.txt file with image paths)
|
11 |
+
train: C:/Users/astoken/projects/yolov5/data/coco/images/train2017
|
12 |
+
val: C:/Users/astoken/projects/yolov5/data/coco/images/train2017
|
13 |
|
14 |
# number of classes
|
15 |
nc: 80
|
train.py
CHANGED
@@ -196,7 +196,7 @@ def train(hyp):
|
|
196 |
c = torch.tensor(labels[:, 0]) # classes
|
197 |
# cf = torch.bincount(c.long(), minlength=nc) + 1.
|
198 |
# model._initialize_biases(cf.to(device))
|
199 |
-
plot_labels(labels)
|
200 |
tb_writer.add_histogram('classes', c, 0)
|
201 |
|
202 |
# Check anchors
|
|
|
196 |
c = torch.tensor(labels[:, 0]) # classes
|
197 |
# cf = torch.bincount(c.long(), minlength=nc) + 1.
|
198 |
# model._initialize_biases(cf.to(device))
|
199 |
+
plot_labels(labels, save_dir=log_dir)
|
200 |
tb_writer.add_histogram('classes', c, 0)
|
201 |
|
202 |
# Check anchors
|
utils/utils.py
CHANGED
@@ -1025,7 +1025,7 @@ def plot_lr_scheduler(optimizer, scheduler, epochs=300, save_dir='./'):
|
|
1025 |
plt.xlim(0, epochs)
|
1026 |
plt.ylim(0)
|
1027 |
plt.tight_layout()
|
1028 |
-
plt.savefig('LR.png', dpi=200)
|
1029 |
|
1030 |
|
1031 |
def plot_test_txt(): # from utils.utils import *; plot_test()
|
@@ -1088,7 +1088,7 @@ def plot_study_txt(f='study.txt', x=None): # from utils.utils import *; plot_st
|
|
1088 |
plt.savefig(f.replace('.txt', '.png'), dpi=200)
|
1089 |
|
1090 |
|
1091 |
-
def plot_labels(labels):
|
1092 |
# plot dataset labels
|
1093 |
c, b = labels[:, 0], labels[:, 1:].transpose() # classees, boxes
|
1094 |
|
@@ -1109,7 +1109,7 @@ def plot_labels(labels):
|
|
1109 |
ax[2].scatter(b[2], b[3], c=hist2d(b[2], b[3], 90), cmap='jet')
|
1110 |
ax[2].set_xlabel('width')
|
1111 |
ax[2].set_ylabel('height')
|
1112 |
-
plt.savefig('labels.png', dpi=200)
|
1113 |
|
1114 |
|
1115 |
def plot_evolution_results(hyp): # from utils.utils import *; plot_evolution_results(hyp)
|
|
|
1025 |
plt.xlim(0, epochs)
|
1026 |
plt.ylim(0)
|
1027 |
plt.tight_layout()
|
1028 |
+
plt.savefig(os.path.join(save_dir, 'LR.png'), dpi=200)
|
1029 |
|
1030 |
|
1031 |
def plot_test_txt(): # from utils.utils import *; plot_test()
|
|
|
1088 |
plt.savefig(f.replace('.txt', '.png'), dpi=200)
|
1089 |
|
1090 |
|
1091 |
+
def plot_labels(labels, save_dir= '.'):
|
1092 |
# plot dataset labels
|
1093 |
c, b = labels[:, 0], labels[:, 1:].transpose() # classees, boxes
|
1094 |
|
|
|
1109 |
ax[2].scatter(b[2], b[3], c=hist2d(b[2], b[3], 90), cmap='jet')
|
1110 |
ax[2].set_xlabel('width')
|
1111 |
ax[2].set_ylabel('height')
|
1112 |
+
plt.savefig(os.path.join(save_dir,'labels.png'), dpi=200)
|
1113 |
|
1114 |
|
1115 |
def plot_evolution_results(hyp): # from utils.utils import *; plot_evolution_results(hyp)
|