| | import os |
| | import csv |
| | import shutil |
| |
|
| |
|
| | prompt_file = '/group/xihuiliu/sky/reasoning/text_image/benchmark/prompt_200_final.txt' |
| |
|
| | output_csv = "/group/xihuiliu/sky/reasoning/human_eval/text_image.csv" |
| | dest_folder = "/group/xihuiliu/sky/reasoning/human_eval/images_eval/text_image" |
| | os.makedirs(dest_folder, exist_ok=True) |
| |
|
| | folders = [ |
| | "/group/xihuiliu/sky/reasoning/images/text_image_new/bagel", |
| | "/group/xihuiliu/sky/reasoning/images/text_image_new/GPT", |
| | "/group/xihuiliu/sky/reasoning/images/text_image_new/hidream", |
| | "/group/xihuiliu/sky/reasoning/images/text_image_new/janus_pro_7B", |
| | "/group/xihuiliu/sky/reasoning/images/text_image_new/sd30_medium", |
| | ] |
| |
|
| | |
| | indices = [1,11,21,31,41,51,61,71,81,91,101,111,121,131,141,151,161,171,181,191] |
| |
|
| | |
| | with open(prompt_file, 'r', encoding='utf-8') as f: |
| | prompts = [line.strip() for line in f.readlines()] |
| |
|
| | |
| | |
| |
|
| | |
| | image_entries = [] |
| | prompt = [] |
| | |
| |
|
| | for idx in indices: |
| | for folder in folders: |
| | found = False |
| | for ext in ['.png']: |
| | img_name = f"{idx:04d}{ext}" |
| | img_path = os.path.join(folder, img_name) |
| | if os.path.exists(img_path): |
| | model_name = os.path.basename(folder) |
| | |
| | image_entries.append((model_name[:3], img_name)) |
| | |
| | new_img_name = f"{idx:04d}_{model_name}{ext}" |
| | dest_path = os.path.join(dest_folder, new_img_name) |
| | shutil.copy2(img_path, dest_path) |
| | |
| | prompt.append(prompts[idx - 1]) |
| | |
| | found = True |
| | break |
| | if not found: |
| | print(f"Warning: Image {img_name} not found in {folder}") |
| |
|
| | |
| | if not (len(image_entries) == len(prompt)): |
| | print() |
| | raise ValueError("Number of images and lines in prompt files do not match!") |
| |
|
| | |
| | header = [ |
| | 'model_name', 'image_name', 'prompt', |
| | 'correctness_1', 'correctness_2', 'correctness_3', |
| | 'aesthetic_1', 'aesthetic_2', 'aesthetic_3' |
| | ] |
| |
|
| | with open(output_csv, 'w', newline='', encoding='utf-8') as csvfile: |
| | writer = csv.writer(csvfile) |
| | writer.writerow(header) |
| | for idx, (img_path, img_name) in enumerate(image_entries): |
| | row = [ |
| | img_path, |
| | img_name, |
| | prompt[idx], |
| | '', '', '', '', '', '' |
| | ] |
| | writer.writerow(row) |
| |
|
| | print(f"CSV file created as {output_csv}.") |
| |
|