Jirka
commited on
Commit
•
ef6f5b3
1
Parent(s):
670d4ff
rename test
Browse files
eval.py
CHANGED
@@ -5,7 +5,7 @@ from models.experimental import *
|
|
5 |
from utils.datasets import *
|
6 |
|
7 |
|
8 |
-
def
|
9 |
weights=None,
|
10 |
batch_size=16,
|
11 |
imgsz=640,
|
@@ -254,16 +254,16 @@ if __name__ == '__main__':
|
|
254 |
print(opt)
|
255 |
|
256 |
if opt.task in ['val', 'test']: # run normally
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
|
268 |
elif opt.task == 'study': # run over a range of settings and save/plot
|
269 |
for weights in ['yolov5s.pt', 'yolov5m.pt', 'yolov5l.pt', 'yolov5x.pt', 'yolov3-spp.pt']:
|
@@ -272,7 +272,7 @@ if __name__ == '__main__':
|
|
272 |
y = [] # y axis
|
273 |
for i in x: # img-size
|
274 |
print('\nRunning %s point %s...' % (f, i))
|
275 |
-
r, _, t =
|
276 |
y.append(r + t) # results and times
|
277 |
np.savetxt(f, y, fmt='%10.4g') # save
|
278 |
os.system('zip -r study.zip study_*.txt')
|
|
|
5 |
from utils.datasets import *
|
6 |
|
7 |
|
8 |
+
def test(data,
|
9 |
weights=None,
|
10 |
batch_size=16,
|
11 |
imgsz=640,
|
|
|
254 |
print(opt)
|
255 |
|
256 |
if opt.task in ['val', 'test']: # run normally
|
257 |
+
test(opt.data,
|
258 |
+
opt.weights,
|
259 |
+
opt.batch_size,
|
260 |
+
opt.img_size,
|
261 |
+
opt.conf_thres,
|
262 |
+
opt.iou_thres,
|
263 |
+
opt.save_json,
|
264 |
+
opt.single_cls,
|
265 |
+
opt.augment,
|
266 |
+
opt.verbose)
|
267 |
|
268 |
elif opt.task == 'study': # run over a range of settings and save/plot
|
269 |
for weights in ['yolov5s.pt', 'yolov5m.pt', 'yolov5l.pt', 'yolov5x.pt', 'yolov3-spp.pt']:
|
|
|
272 |
y = [] # y axis
|
273 |
for i in x: # img-size
|
274 |
print('\nRunning %s point %s...' % (f, i))
|
275 |
+
r, _, t = test(opt.data, weights, opt.batch_size, i, opt.conf_thres, opt.iou_thres, opt.save_json)
|
276 |
y.append(r + t) # results and times
|
277 |
np.savetxt(f, y, fmt='%10.4g') # save
|
278 |
os.system('zip -r study.zip study_*.txt')
|
train.py
CHANGED
@@ -291,14 +291,14 @@ def train(hyp):
|
|
291 |
ema.update_attr(model, include=['md', 'nc', 'hyp', 'gr', 'names', 'stride'])
|
292 |
final_epoch = epoch + 1 == epochs
|
293 |
if not opt.notest or final_epoch: # Calculate mAP
|
294 |
-
results, maps, times = eval.
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
|
303 |
# Write
|
304 |
with open(results_file, 'a') as f:
|
|
|
291 |
ema.update_attr(model, include=['md', 'nc', 'hyp', 'gr', 'names', 'stride'])
|
292 |
final_epoch = epoch + 1 == epochs
|
293 |
if not opt.notest or final_epoch: # Calculate mAP
|
294 |
+
results, maps, times = eval.test(opt.data,
|
295 |
+
batch_size=batch_size,
|
296 |
+
imgsz=imgsz_test,
|
297 |
+
save_json=final_epoch and opt.data.endswith(os.sep + 'coco.yaml'),
|
298 |
+
model=ema.ema,
|
299 |
+
single_cls=opt.single_cls,
|
300 |
+
dataloader=testloader,
|
301 |
+
save_dir=log_dir)
|
302 |
|
303 |
# Write
|
304 |
with open(results_file, 'a') as f:
|