Update/inplace ops (#5233)
* Clip Objects365 autodownload labels (#5214) Fixes out of bounds labels that seem to affect ~10% of images in dataset. * Inplace opspull/5232/head
parent
0000334a6f
commit
13f7275555
|
@ -63,7 +63,7 @@ download: |
|
||||||
from pycocotools.coco import COCO
|
from pycocotools.coco import COCO
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
from utils.general import download, Path
|
from utils.general import Path, download, np, xyxy2xywhn
|
||||||
|
|
||||||
# Make Directories
|
# Make Directories
|
||||||
dir = Path(yaml['path']) # dataset root dir
|
dir = Path(yaml['path']) # dataset root dir
|
||||||
|
@ -105,7 +105,8 @@ download: |
|
||||||
annIds = coco.getAnnIds(imgIds=im["id"], catIds=catIds, iscrowd=None)
|
annIds = coco.getAnnIds(imgIds=im["id"], catIds=catIds, iscrowd=None)
|
||||||
for a in coco.loadAnns(annIds):
|
for a in coco.loadAnns(annIds):
|
||||||
x, y, w, h = a['bbox'] # bounding box in xywh (xy top-left corner)
|
x, y, w, h = a['bbox'] # bounding box in xywh (xy top-left corner)
|
||||||
x, y = x + w / 2, y + h / 2 # xy to center
|
xyxy = np.array([x, y, x + w, y + h])[None] # pixels(1,4)
|
||||||
file.write(f"{cid} {x / width:.5f} {y / height:.5f} {w / width:.5f} {h / height:.5f}\n")
|
x, y, w, h = xyxy2xywhn(xyxy, w=width, h=height, clip=True)[0] # normalized and clipped
|
||||||
|
file.write(f"{cid} {x:.5f} {y:.5f} {w:.5f} {h:.5f}\n")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
|
@ -139,7 +139,7 @@ def run(weights=ROOT / 'yolov5s.pt', # model.pt path(s)
|
||||||
else:
|
else:
|
||||||
img = torch.from_numpy(img).to(device)
|
img = torch.from_numpy(img).to(device)
|
||||||
img = img.half() if half else img.float() # uint8 to fp16/32
|
img = img.half() if half else img.float() # uint8 to fp16/32
|
||||||
img = img / 255.0 # 0 - 255 to 0.0 - 1.0
|
img /= 255.0 # 0 - 255 to 0.0 - 1.0
|
||||||
if len(img.shape) == 3:
|
if len(img.shape) == 3:
|
||||||
img = img[None] # expand for batch dim
|
img = img[None] # expand for batch dim
|
||||||
t2 = time_sync()
|
t2 = time_sync()
|
||||||
|
|
|
@ -433,7 +433,7 @@ class WandbLogger():
|
||||||
"box_caption": "%s %.3f" % (names[cls], conf),
|
"box_caption": "%s %.3f" % (names[cls], conf),
|
||||||
"scores": {"class_score": conf},
|
"scores": {"class_score": conf},
|
||||||
"domain": "pixel"})
|
"domain": "pixel"})
|
||||||
total_conf = total_conf + conf
|
total_conf += conf
|
||||||
boxes = {"predictions": {"box_data": box_data, "class_labels": names}} # inference-space
|
boxes = {"predictions": {"box_data": box_data, "class_labels": names}} # inference-space
|
||||||
id = self.val_table_path_map[Path(path).name]
|
id = self.val_table_path_map[Path(path).name]
|
||||||
self.result_table.add_data(self.current_epoch,
|
self.result_table.add_data(self.current_epoch,
|
||||||
|
|
Loading…
Reference in New Issue