Repoaner's picture
Upload LLaVA-Next-3D/data_precessing/sam2_tracking.py with huggingface_hub
38f7bca verified
raw
history blame contribute delete
868 Bytes
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)