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_test_mot20.py 2.4KB

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