File size: 612 Bytes
26932f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import json

def map_data(objects,detections, descriptions, extracted_texts, summaries):
    mapped_data = {}
    for (obj_id, file_path, box),det, description, text, summary in zip(objects,detections, descriptions, extracted_texts, summaries):
            mapped_data[obj_id] = {
            "file_path": file_path,
            "box": box,
            "description": description,
            "extracted_text": text,
            "summary": summary
        }

    return mapped_data

def save_mapped_data(mapped_data, output_file):
    with open(output_file, "w") as f:
        json.dump(mapped_data, f, indent=2)