Argoverse.yaml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # YOLOv5 🚀 by Ultralytics, AGPL-3.0 license
  2. # Argoverse-HD dataset (ring-front-center camera) http://www.cs.cmu.edu/~mengtial/proj/streaming/ by Argo AI
  3. # Example usage: python train.py --data Argoverse.yaml
  4. # parent
  5. # ├── yolov5
  6. # └── datasets
  7. # └── Argoverse ← downloads here (31.3 GB)
  8. # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
  9. path: ../datasets/Argoverse # dataset root dir
  10. train: Argoverse-1.1/images/train/ # train images (relative to 'path') 39384 images
  11. val: Argoverse-1.1/images/val/ # val images (relative to 'path') 15062 images
  12. test: Argoverse-1.1/images/test/ # test images (optional) https://eval.ai/web/challenges/challenge-page/800/overview
  13. # Classes
  14. names:
  15. 0: person
  16. 1: bicycle
  17. 2: car
  18. 3: motorcycle
  19. 4: bus
  20. 5: truck
  21. 6: traffic_light
  22. 7: stop_sign
  23. # Download script/URL (optional) ---------------------------------------------------------------------------------------
  24. download: |
  25. import json
  26. from tqdm import tqdm
  27. from utils.general import download, Path
  28. def argoverse2yolo(set):
  29. labels = {}
  30. a = json.load(open(set, "rb"))
  31. for annot in tqdm(a['annotations'], desc=f"Converting {set} to YOLOv5 format..."):
  32. img_id = annot['image_id']
  33. img_name = a['images'][img_id]['name']
  34. img_label_name = f'{img_name[:-3]}txt'
  35. cls = annot['category_id'] # instance class id
  36. x_center, y_center, width, height = annot['bbox']
  37. x_center = (x_center + width / 2) / 1920.0 # offset and scale
  38. y_center = (y_center + height / 2) / 1200.0 # offset and scale
  39. width /= 1920.0 # scale
  40. height /= 1200.0 # scale
  41. img_dir = set.parents[2] / 'Argoverse-1.1' / 'labels' / a['seq_dirs'][a['images'][annot['image_id']]['sid']]
  42. if not img_dir.exists():
  43. img_dir.mkdir(parents=True, exist_ok=True)
  44. k = str(img_dir / img_label_name)
  45. if k not in labels:
  46. labels[k] = []
  47. labels[k].append(f"{cls} {x_center} {y_center} {width} {height}\n")
  48. for k in labels:
  49. with open(k, "w") as f:
  50. f.writelines(labels[k])
  51. # Download
  52. dir = Path(yaml['path']) # dataset root dir
  53. urls = ['https://argoverse-hd.s3.us-east-2.amazonaws.com/Argoverse-HD-Full.zip']
  54. download(urls, dir=dir, delete=False)
  55. # Convert
  56. annotations_dir = 'Argoverse-HD/annotations/'
  57. (dir / 'Argoverse-1.1' / 'tracking').rename(dir / 'Argoverse-1.1' / 'images') # rename 'tracking' to 'images'
  58. for d in "train.json", "val.json":
  59. argoverse2yolo(dir / annotations_dir / d) # convert VisDrone annotations to YOLO labels