glenn-jocher commited on
Commit
13f7275
1 Parent(s): 0000334

Update/inplace ops (#5233)

Browse files

* Clip Objects365 autodownload labels (#5214)

Fixes out of bounds labels that seem to affect ~10% of images in dataset.

* Inplace ops

data/Objects365.yaml CHANGED
@@ -63,7 +63,7 @@ download: |
63
  from pycocotools.coco import COCO
64
  from tqdm import tqdm
65
 
66
- from utils.general import download, Path
67
 
68
  # Make Directories
69
  dir = Path(yaml['path']) # dataset root dir
@@ -105,7 +105,8 @@ download: |
105
  annIds = coco.getAnnIds(imgIds=im["id"], catIds=catIds, iscrowd=None)
106
  for a in coco.loadAnns(annIds):
107
  x, y, w, h = a['bbox'] # bounding box in xywh (xy top-left corner)
108
- x, y = x + w / 2, y + h / 2 # xy to center
109
- file.write(f"{cid} {x / width:.5f} {y / height:.5f} {w / width:.5f} {h / height:.5f}\n")
 
110
  except Exception as e:
111
  print(e)
 
63
  from pycocotools.coco import COCO
64
  from tqdm import tqdm
65
 
66
+ from utils.general import Path, download, np, xyxy2xywhn
67
 
68
  # Make Directories
69
  dir = Path(yaml['path']) # dataset root dir
 
105
  annIds = coco.getAnnIds(imgIds=im["id"], catIds=catIds, iscrowd=None)
106
  for a in coco.loadAnns(annIds):
107
  x, y, w, h = a['bbox'] # bounding box in xywh (xy top-left corner)
108
+ xyxy = np.array([x, y, x + w, y + h])[None] # pixels(1,4)
109
+ x, y, w, h = xyxy2xywhn(xyxy, w=width, h=height, clip=True)[0] # normalized and clipped
110
+ file.write(f"{cid} {x:.5f} {y:.5f} {w:.5f} {h:.5f}\n")
111
  except Exception as e:
112
  print(e)
detect.py CHANGED
@@ -139,7 +139,7 @@ def run(weights=ROOT / 'yolov5s.pt', # model.pt path(s)
139
  else:
140
  img = torch.from_numpy(img).to(device)
141
  img = img.half() if half else img.float() # uint8 to fp16/32
142
- img = img / 255.0 # 0 - 255 to 0.0 - 1.0
143
  if len(img.shape) == 3:
144
  img = img[None] # expand for batch dim
145
  t2 = time_sync()
 
139
  else:
140
  img = torch.from_numpy(img).to(device)
141
  img = img.half() if half else img.float() # uint8 to fp16/32
142
+ img /= 255.0 # 0 - 255 to 0.0 - 1.0
143
  if len(img.shape) == 3:
144
  img = img[None] # expand for batch dim
145
  t2 = time_sync()
utils/loggers/wandb/wandb_utils.py CHANGED
@@ -433,7 +433,7 @@ class WandbLogger():
433
  "box_caption": "%s %.3f" % (names[cls], conf),
434
  "scores": {"class_score": conf},
435
  "domain": "pixel"})
436
- total_conf = total_conf + conf
437
  boxes = {"predictions": {"box_data": box_data, "class_labels": names}} # inference-space
438
  id = self.val_table_path_map[Path(path).name]
439
  self.result_table.add_data(self.current_epoch,
 
433
  "box_caption": "%s %.3f" % (names[cls], conf),
434
  "scores": {"class_score": conf},
435
  "domain": "pixel"})
436
+ total_conf += conf
437
  boxes = {"predictions": {"box_data": box_data, "class_labels": names}} # inference-space
438
  id = self.val_table_path_map[Path(path).name]
439
  self.result_table.add_data(self.current_epoch,