You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 line
2.7KB

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