File size: 278 Bytes
aa03424
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
import json
import os
from pathlib import Path

image_paths = os.listdir('../images')

metadata = {}
for image_path in image_paths:
    caption = Path(image_path).stem
    metadata[image_path] = caption

with open('metadata.json', 'w') as f:
    json.dump(metadata, f, indent=4)