glenn-jocher commited on
Commit
0c26c4e
1 Parent(s): 9b0f6e3

Increase pycocotools robustness (#1396)

Browse files
Files changed (2) hide show
  1. test.py +2 -3
  2. train.py +1 -1
test.py CHANGED
@@ -86,8 +86,7 @@ def test(data,
86
  img = torch.zeros((1, 3, imgsz, imgsz), device=device) # init img
87
  _ = model(img.half() if half else img) if device.type != 'cpu' else None # run once
88
  path = data['test'] if opt.task == 'test' else data['val'] # path to val/test images
89
- dataloader = create_dataloader(path, imgsz, batch_size, model.stride.max(), opt,
90
- hyp=None, augment=False, cache=False, pad=0.5, rect=True)[0]
91
 
92
  seen = 0
93
  names = {k: v for k, v in enumerate(model.names if hasattr(model, 'names') else model.module.names)}
@@ -166,7 +165,7 @@ def test(data,
166
  box[:, :2] -= box[:, 2:] / 2 # xy center to top-left corner
167
  for p, b in zip(pred.tolist(), box.tolist()):
168
  jdict.append({'image_id': int(image_id) if image_id.isnumeric() else image_id,
169
- 'category_id': coco91class[int(p[5])],
170
  'bbox': [round(x, 3) for x in b],
171
  'score': round(p[4], 5)})
172
 
 
86
  img = torch.zeros((1, 3, imgsz, imgsz), device=device) # init img
87
  _ = model(img.half() if half else img) if device.type != 'cpu' else None # run once
88
  path = data['test'] if opt.task == 'test' else data['val'] # path to val/test images
89
+ dataloader = create_dataloader(path, imgsz, batch_size, model.stride.max(), opt, pad=0.5, rect=True)[0]
 
90
 
91
  seen = 0
92
  names = {k: v for k, v in enumerate(model.names if hasattr(model, 'names') else model.module.names)}
 
165
  box[:, :2] -= box[:, 2:] / 2 # xy center to top-left corner
166
  for p, b in zip(pred.tolist(), box.tolist()):
167
  jdict.append({'image_id': int(image_id) if image_id.isnumeric() else image_id,
168
+ 'category_id': coco91class[int(p[5])] if is_coco else int(p[5]),
169
  'bbox': [round(x, 3) for x in b],
170
  'score': round(p[4], 5)})
171
 
train.py CHANGED
@@ -183,7 +183,7 @@ def train(hyp, opt, device, tb_writer=None, wandb=None):
183
  if rank in [-1, 0]:
184
  ema.updates = start_epoch * nb // accumulate # set EMA updates
185
  testloader = create_dataloader(test_path, imgsz_test, total_batch_size, gs, opt,
186
- hyp=hyp, augment=False, cache=opt.cache_images and not opt.notest, rect=True,
187
  rank=-1, world_size=opt.world_size, workers=opt.workers)[0] # testloader
188
 
189
  if not opt.resume:
 
183
  if rank in [-1, 0]:
184
  ema.updates = start_epoch * nb // accumulate # set EMA updates
185
  testloader = create_dataloader(test_path, imgsz_test, total_batch_size, gs, opt,
186
+ hyp=hyp, cache=opt.cache_images and not opt.notest, rect=True,
187
  rank=-1, world_size=opt.world_size, workers=opt.workers)[0] # testloader
188
 
189
  if not opt.resume: