|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
path: ../datasets/Argoverse |
|
train: Argoverse-1.1/images/train/ |
|
val: Argoverse-1.1/images/val/ |
|
test: Argoverse-1.1/images/test/ |
|
|
|
|
|
nc: 8 |
|
names: ['person', 'bicycle', 'car', 'motorcycle', 'bus', 'truck', 'traffic_light', 'stop_sign'] |
|
|
|
|
|
|
|
download: | |
|
import json |
|
|
|
from tqdm import tqdm |
|
from utils.general import download, Path |
|
|
|
|
|
def argoverse2yolo(set): |
|
labels = {} |
|
a = json.load(open(set, "rb")) |
|
for annot in tqdm(a['annotations'], desc=f"Converting {set} to YOLOv5 format..."): |
|
img_id = annot['image_id'] |
|
img_name = a['images'][img_id]['name'] |
|
img_label_name = f'{img_name[:-3]}txt' |
|
|
|
cls = annot['category_id'] |
|
x_center, y_center, width, height = annot['bbox'] |
|
x_center = (x_center + width / 2) / 1920.0 |
|
y_center = (y_center + height / 2) / 1200.0 |
|
width /= 1920.0 |
|
height /= 1200.0 |
|
|
|
img_dir = set.parents[2] / 'Argoverse-1.1' / 'labels' / a['seq_dirs'][a['images'][annot['image_id']]['sid']] |
|
if not img_dir.exists(): |
|
img_dir.mkdir(parents=True, exist_ok=True) |
|
|
|
k = str(img_dir / img_label_name) |
|
if k not in labels: |
|
labels[k] = [] |
|
labels[k].append(f"{cls} {x_center} {y_center} {width} {height}\n") |
|
|
|
for k in labels: |
|
with open(k, "w") as f: |
|
f.writelines(labels[k]) |
|
|
|
|
|
|
|
dir = Path('../datasets/Argoverse') |
|
urls = ['https://argoverse-hd.s3.us-east-2.amazonaws.com/Argoverse-HD-Full.zip'] |
|
download(urls, dir=dir, delete=False) |
|
|
|
|
|
annotations_dir = 'Argoverse-HD/annotations/' |
|
(dir / 'Argoverse-1.1' / 'tracking').rename(dir / 'Argoverse-1.1' / 'images') |
|
for d in "train.json", "val.json": |
|
argoverse2yolo(dir / annotations_dir / d) |
|
|