Browse Source

glob search bug fix #77

5.0
Glenn Jocher 4 years ago
parent
commit
c5966abba8
4 changed files with 14 additions and 3 deletions
  1. +1
    -1
      test.py
  2. +2
    -2
      train.py
  3. +1
    -0
      utils/activations.py
  4. +10
    -0
      utils/utils.py

+ 1
- 1
test.py View File

@@ -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'

+ 2
- 2
train.py View File

@@ -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)

+ 1
- 0
utils/activations.py View File

@@ -1,4 +1,5 @@
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn as nn


+ 10
- 0
utils/utils.py View File

@@ -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

Loading…
Cancel
Save