|
import os |
|
import json |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
image_dir = "leftImg8bit/train" |
|
conditioning_dir = "gtCoarse/train" |
|
|
|
|
|
jsonl_filename = "train.jsonl" |
|
|
|
|
|
dataset_entries = [] |
|
|
|
|
|
for city_folder in os.listdir(image_dir): |
|
city_dir = os.path.join(image_dir, city_folder) |
|
|
|
|
|
for image_filename in os.listdir(city_dir): |
|
|
|
parts = image_filename.split("_") |
|
city = parts[0] |
|
seq = parts[1] |
|
frame = parts[2] |
|
|
|
|
|
image_path = os.path.join(city_dir, image_filename) |
|
conditioning_image_filename = f"{city}_{seq}_{frame}_gtCoarse_color.png" |
|
conditioning_image_path = os.path.join(conditioning_dir, city_folder+"/"+conditioning_image_filename) |
|
|
|
|
|
entry = { |
|
"text": "A view to a street from a car's front window", |
|
"image": image_path, |
|
"conditioning_image": conditioning_image_path, |
|
} |
|
|
|
|
|
dataset_entries.append(entry) |
|
|
|
|
|
with open(jsonl_filename, "w") as jsonl_file: |
|
|
|
for entry in dataset_entries: |
|
jsonl_file.write(json.dumps(entry) + "\n") |
|
|
|
print(f"JSON Lines file '{jsonl_filename}' has been created.") |
|
|