glenn-jocher commited on
Commit
ee8988b
·
1 Parent(s): 7a00a5e

datasets.py self.batch_shapes fix

Browse files
Files changed (3) hide show
  1. models/yolo.py +0 -1
  2. test.py +2 -2
  3. utils/datasets.py +1 -1
models/yolo.py CHANGED
@@ -20,7 +20,6 @@ class Detect(nn.Module):
20
  self.export = False # onnx export
21
 
22
  def forward(self, x):
23
- x = x.copy()
24
  z = [] # inference output
25
  self.training |= self.export
26
  for i in range(self.nl):
 
20
  self.export = False # onnx export
21
 
22
  def forward(self, x):
 
23
  z = [] # inference output
24
  self.training |= self.export
25
  for i in range(self.nl):
test.py CHANGED
@@ -244,7 +244,7 @@ if __name__ == '__main__':
244
  print(opt)
245
 
246
  # task = 'val', 'test', 'study'
247
- if opt.task == 'val': # (default) run normally
248
  test(opt.data,
249
  opt.weights,
250
  opt.batch_size,
@@ -258,7 +258,7 @@ if __name__ == '__main__':
258
  elif opt.task == 'study': # run over a range of settings and save/plot
259
  for weights in ['yolov5s.pt', 'yolov5m.pt', 'yolov5l.pt', 'yolov5x.pt', 'yolov3-spp.pt']:
260
  f = 'study_%s_%s.txt' % (Path(opt.data).stem, Path(weights).stem) # filename to save to
261
- x = list(range(256, 1024, 32)) # x axis
262
  y = [] # y axis
263
  for i in x: # img-size
264
  print('\nRunning %s point %s...' % (f, i))
 
244
  print(opt)
245
 
246
  # task = 'val', 'test', 'study'
247
+ if opt.task in ['val', 'test']: # (default) run normally
248
  test(opt.data,
249
  opt.weights,
250
  opt.batch_size,
 
258
  elif opt.task == 'study': # run over a range of settings and save/plot
259
  for weights in ['yolov5s.pt', 'yolov5m.pt', 'yolov5l.pt', 'yolov5x.pt', 'yolov3-spp.pt']:
260
  f = 'study_%s_%s.txt' % (Path(opt.data).stem, Path(weights).stem) # filename to save to
261
+ x = list(range(256, 1024, 64)) # x axis
262
  y = [] # y axis
263
  for i in x: # img-size
264
  print('\nRunning %s point %s...' % (f, i))
utils/datasets.py CHANGED
@@ -322,7 +322,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing
322
  elif mini > 1:
323
  shapes[i] = [1, 1 / mini]
324
 
325
- self.batch_shapes = np.ceil(np.array(shapes) * img_size / 64.).astype(np.int) * 64
326
 
327
  # Cache labels
328
  self.imgs = [None] * n
 
322
  elif mini > 1:
323
  shapes[i] = [1, 1 / mini]
324
 
325
+ self.batch_shapes = np.round(np.array(shapes) * img_size / 32. + 1.).astype(np.int) * 32
326
 
327
  # Cache labels
328
  self.imgs = [None] * n