json2md.py 476 Bytes
Newer Older
MPU王荣胜's avatar
MPU王荣胜 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import json
from tqdm import tqdm


with open('./openi-en.json') as f:
    data = json.load(f)

markdown_content = ''
for i in tqdm(range(len(data['annotations']))):
    # 获取字典对象
    #img = data['annotations'][i]['image_id']
    annotation = data['annotations'][i]['caption']
    markdown_content = markdown_content + str(annotation) + '\n\n'

with open('openi-en-md.md', 'w') as f1:
    f1.write(markdown_content)

print(len(data['annotations']))