|
import json
|
|
|
|
|
|
json_file = 'd:/Dropbox/YandexDisk/Dataset/output.json'
|
|
|
|
|
|
with open(json_file, 'r') as f:
|
|
data = json.load(f)
|
|
|
|
|
|
new_data = []
|
|
|
|
for item in data:
|
|
conversations = item['conversations']
|
|
for conv in conversations:
|
|
if conv['from'] == 'user':
|
|
query = conv['value']
|
|
elif conv['from'] == 'assistant':
|
|
response = conv['value']
|
|
|
|
new_item = {
|
|
"query": query,
|
|
"response": response,
|
|
"images": item['image']
|
|
}
|
|
new_data.append(new_item)
|
|
|
|
|
|
new_json_file = 'd:/Dropbox/YandexDisk/Dataset/new2_vl_data.json'
|
|
with open(new_json_file, 'w') as f:
|
|
json.dump(new_data, f, indent=4) |