[1180c1]: / llava / data / remove_instructions.py

Download this file

32 lines (23 with data), 757 Bytes

 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
29
30
31
"""
Usage:
python3 pretty_json.py --in in.json --out out.json
"""
import argparse
import json
from tqdm import tqdm
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--in-file", type=str, required=True)
parser.add_argument("--out-file", type=str, required=True)
args = parser.parse_args()
with open(args.in_file, "r") as fin:
data = json.load(fin)
# remove instruction
new_data = []
for line in tqdm(data):
if line['conversatons'][0]['from'] == 'human':
line['conversatons'][0]['value'] = '<image>'
# import pdb; pdb.set_trace()
new_data.append(line)
with open(args.out_file, "w") as fout:
json.dump(new_data, fout, indent=2)