|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
path: ../datasets/SKU-110K |
|
train: train.txt |
|
val: val.txt |
|
test: test.txt |
|
|
|
|
|
nc: 1 |
|
names: ['object'] |
|
|
|
|
|
|
|
download: | |
|
import shutil |
|
from tqdm.auto import tqdm |
|
from utils.general import np, pd, Path, download, xyxy2xywh |
|
|
|
|
|
|
|
dir = Path(yaml['path']) |
|
parent = Path(dir.parent) |
|
urls = ['http://trax-geometry.s3.amazonaws.com/cvpr_challenge/SKU110K_fixed.tar.gz'] |
|
download(urls, dir=parent, delete=False) |
|
|
|
|
|
if dir.exists(): |
|
shutil.rmtree(dir) |
|
(parent / 'SKU110K_fixed').rename(dir) |
|
(dir / 'labels').mkdir(parents=True, exist_ok=True) |
|
|
|
|
|
names = 'image', 'x1', 'y1', 'x2', 'y2', 'class', 'image_width', 'image_height' |
|
for d in 'annotations_train.csv', 'annotations_val.csv', 'annotations_test.csv': |
|
x = pd.read_csv(dir / 'annotations' / d, names=names).values |
|
images, unique_images = x[:, 0], np.unique(x[:, 0]) |
|
with open((dir / d).with_suffix('.txt').__str__().replace('annotations_', ''), 'w') as f: |
|
f.writelines(f'./images/{s}\n' for s in unique_images) |
|
for im in tqdm(unique_images, desc=f'Converting {dir / d}'): |
|
cls = 0 # single-class dataset |
|
with open((dir / 'labels' / im).with_suffix('.txt'), 'a') as f: |
|
for r in x[images == im]: |
|
w, h = r[6], r[7] |
|
xywh = xyxy2xywh(np.array([[r[1] / w, r[2] / h, r[3] / w, r[4] / h]]))[0] |
|
f.write(f"{cls} {xywh[0]:.5f} {xywh[1]:.5f} {xywh[2]:.5f} {xywh[3]:.5f}\n") |
|
|