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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. # Download/unzip images
  10. d='../argoverse/' # unzip directory
  11. mkdir $d
  12. url=https://argoverse-hd.s3.us-east-2.amazonaws.com/
  13. f=Argoverse-HD-Full.zip
  14. wget $url$f -O $f && unzip -q $f -d $d && rm $f &# download, unzip, remove in background
  15. wait # finish background tasks
  16. cd ../argoverse/Argoverse-1.1/
  17. ln -s tracking images
  18. cd ../Argoverse-HD/annotations/
  19. python3 - "$@" <<END
  20. import json
  21. from pathlib import Path
  22. annotation_files = ["train.json", "val.json"]
  23. print("Converting annotations to YOLOv5 format...")
  24. for val in annotation_files:
  25. a = json.load(open(val, "rb"))
  26. label_dict = {}
  27. for annot in a['annotations']:
  28. img_id = annot['image_id']
  29. img_name = a['images'][img_id]['name']
  30. img_label_name = img_name[:-3] + "txt"
  31. obj_class = annot['category_id']
  32. x_center, y_center, width, height = annot['bbox']
  33. x_center = (x_center + width / 2) / 1920. # offset and scale
  34. y_center = (y_center + height / 2) / 1200. # offset and scale
  35. width /= 1920. # scale
  36. height /= 1200. # scale
  37. img_dir = "./labels/" + a['seq_dirs'][a['images'][annot['image_id']]['sid']]
  38. Path(img_dir).mkdir(parents=True, exist_ok=True)
  39. if img_dir + "/" + img_label_name not in label_dict:
  40. label_dict[img_dir + "/" + img_label_name] = []
  41. label_dict[img_dir + "/" + img_label_name].append(f"{obj_class} {x_center} {y_center} {width} {height}\n")
  42. for filename in label_dict:
  43. with open(filename, "w") as file:
  44. for string in label_dict[filename]:
  45. file.write(string)
  46. END
  47. mv ./labels ../../Argoverse-1.1/