yolov5-face icon indicating copy to clipboard operation
yolov5-face copied to clipboard

Why am I having this problem? AssertionError: No results.txt files found in /content/yolov5-face/runs/train/exp, nothing to plot.

Open m-hajiabadi opened this issue 1 year ago • 4 comments

When I run this command: !python3 train.py --data data/widerface.yaml --cfg models/yolov5s.yaml --weights yolovs-face.pt --epochs 1 I run into this problem. Traceback (most recent call last): File "train.py", line 513, in train(hyp, opt, device, tb_writer, wandb) File "train.py", line 400, in train plot_results(save_dir=save_dir) # save as results.png File "/content/yolov5-face/utils/plots.py", line 393, in plot_results assert len(files), 'No results.txt files found in %s, nothing to plot.' % os.path.abspath(save_dir) AssertionError: No results.txt files found in /content/yolov5-face/runs/train/exp, nothing to plot.

m-hajiabadi avatar Jul 06 '22 11:07 m-hajiabadi

It seems that the lack of model results makes visualization impossible.  Breakpoint debugging is recommended to locate faults. 

bobo0810 avatar Jul 06 '22 12:07 bobo0810

It seems that the lack of model results makes visualization impossible.  Breakpoint debugging is recommended to locate faults.

Yes, you are right. https://github.com/deepcam-cn/yolov5-face/blob/d3505409a6e70f8f878b18686265cf18e04deea6/train.py#L150 This block of code doesn't run because ckpt doesn't have "training_results".

# Results
       if ckpt.get('training_results') is not None:
           with open(results_file, 'w') as file:
               file.write(ckpt['training_results'])  # write results.txt

m-hajiabadi avatar Jul 07 '22 07:07 m-hajiabadi

why cases this problem?do you solve it?

I don't know. I still haven't been able to solve it.

m-hajiabadi avatar Jul 26 '22 04:07 m-hajiabadi

I find the problem. If you only use single-GPU and set epoch <20, this block will not work. The solution is to delete epoch>20. I install wandb to view the results. I've run it successfully.

This line of code is on 330 lines of the source code train.py.

# DDP process 0 or single-GPU
        if rank in [-1, 0] and epoch > 20:
            # mAP
            if ema:
                ema.update_attr(model, include=['yaml', 'nc', 'hyp', 'gr', 'names', 'stride', 'class_weights'])
            final_epoch = epoch + 1 == epochs
            if not opt.notest or final_epoch:  # Calculate mAP
                results, maps, times = test.test(opt.data,
                                                 batch_size=total_batch_size,
                                                 imgsz=imgsz_test,
                                                 model=ema.ema,
                                                 single_cls=opt.single_cls,
                                                 dataloader=testloader,
                                                 save_dir=save_dir,
                                                 plots=False,
                                                 log_imgs=opt.log_imgs if wandb else 0)

            # Write
            with open(results_file, 'a') as f:
                f.write(s + '%10.4g' * 7 % results + '\n')  # P, R, [email protected], [email protected], val_loss(box, obj, cls)
            if len(opt.name) and opt.bucket:
                os.system('gsutil cp %s gs://%s/results/results%s.txt' % (results_file, opt.bucket, opt.name))

jijunhao avatar Jul 27 '22 03:07 jijunhao

@jijunhao I confirm this is the root cause. Just delete that and epoch>20 if you want to visualize at the very beginning of your training.

wjtan99 avatar Aug 19 '22 15:08 wjtan99

I find the problem. If you only use single-GPU and set epoch <20, this block will not work. The solution is to delete epoch>20. I install wandb to view the results. I've run it successfully.

This line of code is on 330 lines of the source code train.py.

# DDP process 0 or single-GPU
        if rank in [-1, 0] and epoch > 20:
            # mAP
            if ema:
                ema.update_attr(model, include=['yaml', 'nc', 'hyp', 'gr', 'names', 'stride', 'class_weights'])
            final_epoch = epoch + 1 == epochs
            if not opt.notest or final_epoch:  # Calculate mAP
                results, maps, times = test.test(opt.data,
                                                 batch_size=total_batch_size,
                                                 imgsz=imgsz_test,
                                                 model=ema.ema,
                                                 single_cls=opt.single_cls,
                                                 dataloader=testloader,
                                                 save_dir=save_dir,
                                                 plots=False,
                                                 log_imgs=opt.log_imgs if wandb else 0)

            # Write
            with open(results_file, 'a') as f:
                f.write(s + '%10.4g' * 7 % results + '\n')  # P, R, [email protected], [email protected], val_loss(box, obj, cls)
            if len(opt.name) and opt.bucket:
                os.system('gsutil cp %s gs://%s/results/results%s.txt' % (results_file, opt.bucket, opt.name))

you are right.thank you

hegangjian123456 avatar Oct 21 '23 09:10 hegangjian123456

@jijunhao I confirm this is the root cause. Just delete that and epoch>20 if you want to visualize at the very beginning of your training.

thank you

junhao9193 avatar Feb 19 '24 03:02 junhao9193