diff --git a/test.py b/test.py index ee2b0ab..292c4c4 100644 --- a/test.py +++ b/test.py @@ -255,7 +255,7 @@ if __name__ == '__main__': opt = parser.parse_args() opt.img_size = check_img_size(opt.img_size) opt.save_json = opt.save_json or opt.data.endswith('coco.yaml') - opt.data = glob.glob('./**/' + opt.data, recursive=True)[0] # find file + opt.data = check_file(opt.data) # check file print(opt) # task = 'val', 'test', 'study' diff --git a/train.py b/train.py index a3112ee..b615b47 100644 --- a/train.py +++ b/train.py @@ -384,8 +384,8 @@ if __name__ == '__main__': parser.add_argument('--single-cls', action='store_true', help='train as single-class dataset') opt = parser.parse_args() opt.weights = last if opt.resume else opt.weights - opt.cfg = glob.glob('./**/' + opt.cfg, recursive=True)[0] # find file - opt.data = glob.glob('./**/' + opt.data, recursive=True)[0] # find file + opt.cfg = check_file(opt.cfg) # check file + opt.data = check_file(opt.data) # check file print(opt) opt.img_size.extend([opt.img_size[-1]] * (2 - len(opt.img_size))) # extend to 2 sizes (train, test) device = torch_utils.select_device(opt.device, apex=mixed_precision, batch_size=opt.batch_size) diff --git a/utils/activations.py b/utils/activations.py index 0d23a92..cf226fe 100644 --- a/utils/activations.py +++ b/utils/activations.py @@ -1,4 +1,5 @@ import torch +import torch.nn as nn import torch.nn.functional as F import torch.nn as nn diff --git a/utils/utils.py b/utils/utils.py index 860dfe5..bce8a10 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -64,6 +64,16 @@ def check_best_possible_recall(dataset, anchors, thr): 'Compute new anchors with utils.utils.kmeans_anchors() and update model before training.' % bpr +def check_file(file): + # Searches for file if not found locally + if os.path.isfile(file): + return file + else: + files = glob.glob('./**/' + file, recursive=True) # find file + assert len(files), 'File Not Found: %s' % file # assert file was found + return files[0] # return first file if multiple found + + def make_divisible(x, divisor): # Returns x evenly divisble by divisor return math.ceil(x / divisor) * divisor