Skip to content

Commit 13f7275

Browse files
authored
Update/inplace ops (#5233)
* Clip Objects365 autodownload labels (#5214) Fixes out of bounds labels that seem to affect ~10% of images in dataset. * Inplace ops
1 parent 0000334 commit 13f7275

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

data/Objects365.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ download: |
6363
from pycocotools.coco import COCO
6464
from tqdm import tqdm
6565
66-
from utils.general import download, Path
66+
from utils.general import Path, download, np, xyxy2xywhn
6767
6868
# Make Directories
6969
dir = Path(yaml['path']) # dataset root dir
@@ -105,7 +105,8 @@ download: |
105105
annIds = coco.getAnnIds(imgIds=im["id"], catIds=catIds, iscrowd=None)
106106
for a in coco.loadAnns(annIds):
107107
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")
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")
110111
except Exception as e:
111112
print(e)

detect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def wrap_frozen_graph(gd, inputs, outputs):
139139
else:
140140
img = torch.from_numpy(img).to(device)
141141
img = img.half() if half else img.float() # uint8 to fp16/32
142-
img = img / 255.0 # 0 - 255 to 0.0 - 1.0
142+
img /= 255.0 # 0 - 255 to 0.0 - 1.0
143143
if len(img.shape) == 3:
144144
img = img[None] # expand for batch dim
145145
t2 = time_sync()

utils/loggers/wandb/wandb_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def log_training_progress(self, predn, path, names):
433433
"box_caption": "%s %.3f" % (names[cls], conf),
434434
"scores": {"class_score": conf},
435435
"domain": "pixel"})
436-
total_conf = total_conf + conf
436+
total_conf += conf
437437
boxes = {"predictions": {"box_data": box_data, "class_labels": names}} # inference-space
438438
id = self.val_table_path_map[Path(path).name]
439439
self.result_table.add_data(self.current_epoch,

0 commit comments

Comments
 (0)