|
| 1 | +#!/bin/bash |
| 2 | +# Argoverse-HD dataset (ring-front-center camera) http://www.cs.cmu.edu/~mengtial/proj/streaming/ |
| 3 | +# Download command: bash data/scripts/get_argoverse_hd.sh |
| 4 | +# Train command: python train.py --data argoverse_hd.yaml |
| 5 | +# Default dataset location is next to YOLOv5: |
| 6 | +# /parent_folder |
| 7 | +# /argoverse |
| 8 | +# /yolov5 |
| 9 | + |
| 10 | +# Download/unzip images |
| 11 | +d='../argoverse/' # unzip directory |
| 12 | +mkdir $d |
| 13 | +url=https://argoverse-hd.s3.us-east-2.amazonaws.com/ |
| 14 | +f=Argoverse-HD-Full.zip |
| 15 | +curl -L $url$f -o $f && unzip -q $f -d $d && rm $f &# download, unzip, remove in background |
| 16 | +wait # finish background tasks |
| 17 | + |
| 18 | +cd ../argoverse/Argoverse-1.1/ |
| 19 | +ln -s tracking images |
| 20 | + |
| 21 | +cd ../Argoverse-HD/annotations/ |
| 22 | + |
| 23 | +python3 - "$@" <<END |
| 24 | +import json |
| 25 | +from pathlib import Path |
| 26 | +
|
| 27 | +annotation_files = ["train.json", "val.json"] |
| 28 | +print("Converting annotations to YOLOv5 format...") |
| 29 | +
|
| 30 | +for val in annotation_files: |
| 31 | + a = json.load(open(val, "rb")) |
| 32 | +
|
| 33 | + label_dict = {} |
| 34 | + for annot in a['annotations']: |
| 35 | + img_id = annot['image_id'] |
| 36 | + img_name = a['images'][img_id]['name'] |
| 37 | + img_label_name = img_name[:-3] + "txt" |
| 38 | +
|
| 39 | + obj_class = annot['category_id'] |
| 40 | + x_center, y_center, width, height = annot['bbox'] |
| 41 | + x_center = (x_center + width / 2) / 1920. # offset and scale |
| 42 | + y_center = (y_center + height / 2) / 1200. # offset and scale |
| 43 | + width /= 1920. # scale |
| 44 | + height /= 1200. # scale |
| 45 | +
|
| 46 | + img_dir = "./labels/" + a['seq_dirs'][a['images'][annot['image_id']]['sid']] |
| 47 | +
|
| 48 | + Path(img_dir).mkdir(parents=True, exist_ok=True) |
| 49 | +
|
| 50 | + if img_dir + "/" + img_label_name not in label_dict: |
| 51 | + label_dict[img_dir + "/" + img_label_name] = [] |
| 52 | +
|
| 53 | + label_dict[img_dir + "/" + img_label_name].append(f"{obj_class} {x_center} {y_center} {width} {height}\n") |
| 54 | +
|
| 55 | + for filename in label_dict: |
| 56 | + with open(filename, "w") as file: |
| 57 | + for string in label_dict[filename]: |
| 58 | + file.write(string) |
| 59 | +
|
| 60 | +END |
| 61 | + |
| 62 | +mv ./labels ../../Argoverse-1.1/ |
0 commit comments