| import glob | |
| import copy | |
| import json | |
| import pdb | |
| from tqdm import tqdm | |
| dirs = glob.glob('extra_data/SA-V/sav_train/sav_*') | |
| paths = [] | |
| for dir_ in dirs: | |
| paths += glob.glob(dir_ + '/*_object_*.json') | |
| llava_data = [] | |
| for sample_id, path in enumerate(tqdm(paths)): | |
| data = json.load(open(path, 'r')) | |
| item = {"id": 0, | |
| "video": "", | |
| "conversations": [{"value": "<image> Identify the object according to the following bounding box: \n <OBJ>", "from": "human"}, \ | |
| {"value": "<OBJ>", "from": "gpt"}], | |
| "metadata": {"dataset": "sam2_tracking", "box_info": ""}} | |
| item["id"] = sample_id | |
| item["video"] = path[0:44] + '.mp4' | |
| item["metadata"]["box_info"] = data | |
| llava_data.append(item) | |
| json.dump(llava_data, open('extra_data/annotation/sam2_tracking_llava_format.json', 'w'), indent=4) |