Meta Byte Track
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.

mix_data_ablation.py 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import json
  2. import os
  3. """
  4. cd datasets
  5. mkdir -p mix_mot_ch/annotations
  6. cp mot/annotations/val_half.json mix_mot_ch/annotations/val_half.json
  7. cp mot/annotations/test.json mix_mot_ch/annotations/test.json
  8. cd mix_mot_ch
  9. ln -s ../mot/train mot_train
  10. ln -s ../crowdhuman/CrowdHuman_train crowdhuman_train
  11. ln -s ../crowdhuman/CrowdHuman_val crowdhuman_val
  12. cd ..
  13. """
  14. mot_json = json.load(open('datasets/mot/annotations/train_half.json','r'))
  15. img_list = list()
  16. for img in mot_json['images']:
  17. img['file_name'] = 'mot_train/' + img['file_name']
  18. img_list.append(img)
  19. ann_list = list()
  20. for ann in mot_json['annotations']:
  21. ann_list.append(ann)
  22. video_list = mot_json['videos']
  23. category_list = mot_json['categories']
  24. print('mot17')
  25. max_img = 10000
  26. max_ann = 2000000
  27. max_video = 10
  28. crowdhuman_json = json.load(open('datasets/crowdhuman/annotations/train.json','r'))
  29. img_id_count = 0
  30. for img in crowdhuman_json['images']:
  31. img_id_count += 1
  32. img['file_name'] = 'crowdhuman_train/' + img['file_name']
  33. img['frame_id'] = img_id_count
  34. img['prev_image_id'] = img['id'] + max_img
  35. img['next_image_id'] = img['id'] + max_img
  36. img['id'] = img['id'] + max_img
  37. img['video_id'] = max_video
  38. img_list.append(img)
  39. for ann in crowdhuman_json['annotations']:
  40. ann['id'] = ann['id'] + max_ann
  41. ann['image_id'] = ann['image_id'] + max_img
  42. ann_list.append(ann)
  43. video_list.append({
  44. 'id': max_video,
  45. 'file_name': 'crowdhuman_train'
  46. })
  47. print('crowdhuman_train')
  48. max_img = 30000
  49. max_ann = 10000000
  50. crowdhuman_val_json = json.load(open('datasets/crowdhuman/annotations/val.json','r'))
  51. img_id_count = 0
  52. for img in crowdhuman_val_json['images']:
  53. img_id_count += 1
  54. img['file_name'] = 'crowdhuman_val/' + img['file_name']
  55. img['frame_id'] = img_id_count
  56. img['prev_image_id'] = img['id'] + max_img
  57. img['next_image_id'] = img['id'] + max_img
  58. img['id'] = img['id'] + max_img
  59. img['video_id'] = max_video
  60. img_list.append(img)
  61. for ann in crowdhuman_val_json['annotations']:
  62. ann['id'] = ann['id'] + max_ann
  63. ann['image_id'] = ann['image_id'] + max_img
  64. ann_list.append(ann)
  65. video_list.append({
  66. 'id': max_video,
  67. 'file_name': 'crowdhuman_val'
  68. })
  69. print('crowdhuman_val')
  70. mix_json = dict()
  71. mix_json['images'] = img_list
  72. mix_json['annotations'] = ann_list
  73. mix_json['videos'] = video_list
  74. mix_json['categories'] = category_list
  75. json.dump(mix_json, open('datasets/mix_mot_ch/annotations/train.json','w'))