File size: 704 Bytes
616059a
 
 
 
 
 
 
3e1b1ad
616059a
 
 
 
 
 
 
97f6224
616059a
 
 
97f6224
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
import json
import shutil
from tqdm.notebook import tqdm
lines = []
images = []
i = 1
for ann in tqdm(os.listdir("./data/key")[00:18]):
    i += 1
    if ann != ".ipynb_checkpoints":
        with open("./data/key/" + ann) as f:
            data = json.load(f)
        images.append(ann[:-4] + "jpg")
        line = {"gt_parse": data}
        lines.append(line)
        with open("IdP-donut/train/metadata.jsonll", 'w') as f:
            for i, gt_parse in enumerate(lines):
                line = {"file_name": images[i], "ground_truth": json.dumps(gt_parse)}
                f.write(json.dumps(line) + "\n")
        shutil.copyfile("./data/img/" + images[i], "./IdP-donut/train/" + images[i])