glenn-jocher commited on
Commit
c5966ab
1 Parent(s): ace56eb

glob search bug fix #77

Browse files
Files changed (4) hide show
  1. test.py +1 -1
  2. train.py +2 -2
  3. utils/activations.py +1 -0
  4. utils/utils.py +10 -0
test.py CHANGED
@@ -255,7 +255,7 @@ if __name__ == '__main__':
255
  opt = parser.parse_args()
256
  opt.img_size = check_img_size(opt.img_size)
257
  opt.save_json = opt.save_json or opt.data.endswith('coco.yaml')
258
- opt.data = glob.glob('./**/' + opt.data, recursive=True)[0] # find file
259
  print(opt)
260
 
261
  # task = 'val', 'test', 'study'
 
255
  opt = parser.parse_args()
256
  opt.img_size = check_img_size(opt.img_size)
257
  opt.save_json = opt.save_json or opt.data.endswith('coco.yaml')
258
+ opt.data = check_file(opt.data) # check file
259
  print(opt)
260
 
261
  # task = 'val', 'test', 'study'
train.py CHANGED
@@ -384,8 +384,8 @@ if __name__ == '__main__':
384
  parser.add_argument('--single-cls', action='store_true', help='train as single-class dataset')
385
  opt = parser.parse_args()
386
  opt.weights = last if opt.resume else opt.weights
387
- opt.cfg = glob.glob('./**/' + opt.cfg, recursive=True)[0] # find file
388
- opt.data = glob.glob('./**/' + opt.data, recursive=True)[0] # find file
389
  print(opt)
390
  opt.img_size.extend([opt.img_size[-1]] * (2 - len(opt.img_size))) # extend to 2 sizes (train, test)
391
  device = torch_utils.select_device(opt.device, apex=mixed_precision, batch_size=opt.batch_size)
 
384
  parser.add_argument('--single-cls', action='store_true', help='train as single-class dataset')
385
  opt = parser.parse_args()
386
  opt.weights = last if opt.resume else opt.weights
387
+ opt.cfg = check_file(opt.cfg) # check file
388
+ opt.data = check_file(opt.data) # check file
389
  print(opt)
390
  opt.img_size.extend([opt.img_size[-1]] * (2 - len(opt.img_size))) # extend to 2 sizes (train, test)
391
  device = torch_utils.select_device(opt.device, apex=mixed_precision, batch_size=opt.batch_size)
utils/activations.py CHANGED
@@ -1,4 +1,5 @@
1
  import torch
 
2
  import torch.nn.functional as F
3
  import torch.nn as nn
4
 
 
1
  import torch
2
+ import torch.nn as nn
3
  import torch.nn.functional as F
4
  import torch.nn as nn
5
 
utils/utils.py CHANGED
@@ -64,6 +64,16 @@ def check_best_possible_recall(dataset, anchors, thr):
64
  'Compute new anchors with utils.utils.kmeans_anchors() and update model before training.' % bpr
65
 
66
 
 
 
 
 
 
 
 
 
 
 
67
  def make_divisible(x, divisor):
68
  # Returns x evenly divisble by divisor
69
  return math.ceil(x / divisor) * divisor
 
64
  'Compute new anchors with utils.utils.kmeans_anchors() and update model before training.' % bpr
65
 
66
 
67
+ def check_file(file):
68
+ # Searches for file if not found locally
69
+ if os.path.isfile(file):
70
+ return file
71
+ else:
72
+ files = glob.glob('./**/' + file, recursive=True) # find file
73
+ assert len(files), 'File Not Found: %s' % file # assert file was found
74
+ return files[0] # return first file if multiple found
75
+
76
+
77
  def make_divisible(x, divisor):
78
  # Returns x evenly divisble by divisor
79
  return math.ceil(x / divisor) * divisor