Skip to content

Issue with --evolve #9329

@robinned

Description

@robinned

Search before asking

  • I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

Training

Bug

Hi! First bug report here, so hopefully I've added the right amount of info.

When trying to evolve hyperparameters, train.py throws the below IsADirectoryError. The program appears to work fine if the or opt.evolve on line 486 of train.py is deleted. That's the gist of the issue, below is just some extra info that I came across while trying to figure out why the error happened.

From what I can gather by looking at the code, it seems like when the --evolve flag is given to train.py, the program tries to resume from a previous run (it enters the same block of code as when --resume is given). Looking into the commit history, this commit seems to have changed the if statement on line 486 of train.py to run the if statement's code block when --evolve is passed, while before the commit, passing --evolve made it skip that code block.

(This is the full output from running the reproducible example code)

Cloning into 'yolov5'...
remote: Enumerating objects: 12209, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 12209 (delta 0), reused 4 (delta 0), pack-reused 12197
Receiving objects: 100% (12209/12209), 12.61 MiB | 22.74 MiB/s, done.
Resolving deltas: 100% (8404/8404), done.
/content/yolov5
     |████████████████████████████████| 1.6 MB 4.1 MB/s 
train: weights=yolov5s.pt, cfg=, data=coco128.yaml, hyp=data/hyps/hyp.scratch-low.yaml, epochs=10, batch_size=16, imgsz=640, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, noplots=False, evolve=300, bucket=, cache=ram, image_weights=False, device=, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=8, project=runs/train, name=exp, exist_ok=False, quad=False, cos_lr=False, label_smoothing=0.0, patience=100, freeze=[0], save_period=-1, seed=0, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest
github: up to date with https://github.com/ultralytics/yolov5 ✅
Traceback (most recent call last):
  File "train.py", line 630, in <module>
    main(opt)
  File "train.py", line 494, in main
    d = torch.load(last, map_location='cpu')['opt']
  File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 699, in load
    with _open_file_like(f, 'rb') as opened_file:
  File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 230, in _open_file_like
    return _open_file(name_or_buffer, mode)
  File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 211, in __init__
    super(_open_file, self).__init__(open(name, mode))
IsADirectoryError: [Errno 21] Is a directory: '.'

Environment

-Google Colab Pro
-High Ram and GPU acceleration
-wandb version 0.12.10 installed
-Yolov5s

Minimal Reproducible Example

Running this on a fresh Colab notebook with GPU acceleration will replicate the issue

!git clone https://github.com/ultralytics/yolov5  # clone
%cd yolov5
%pip install -qr requirements.txt  # install

import torch

!python train.py --epochs 10 --data coco128.yaml --weights yolov5s.pt --cache --evolve

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions