File size: 868 Bytes
38f7bca | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 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) |