|
|
import os |
|
|
import csv |
|
|
|
|
|
|
|
|
real_dir = "/home/kalpit/workspace/aigc/data/ShareVeo3/test/0_real" |
|
|
fake_dir = "/home/kalpit/workspace/aigc/data/ShareVeo3/test/1_fake" |
|
|
|
|
|
|
|
|
output_csv = "/home/kalpit/workspace/aigc/repos/DeMamba/veo_test.csv" |
|
|
|
|
|
|
|
|
def get_image_paths(directory, label): |
|
|
image_paths = [] |
|
|
for root, _, files in os.walk(directory): |
|
|
for file in files: |
|
|
if file.lower().endswith(('.png', '.jpg', '.jpeg')): |
|
|
full_path = os.path.join(root, file) |
|
|
image_paths.append({ |
|
|
"content_path": full_path, |
|
|
"frame_seq": [full_path], |
|
|
"label": label |
|
|
}) |
|
|
return image_paths |
|
|
|
|
|
|
|
|
data = [] |
|
|
data.extend(get_image_paths(real_dir, 0)) |
|
|
data.extend(get_image_paths(fake_dir, 1)) |
|
|
|
|
|
|
|
|
with open(output_csv, 'w', newline='', encoding='utf-8') as csvfile: |
|
|
fieldnames = ["content_path", "frame_seq", "label"] |
|
|
writer = csv.DictWriter(csvfile, fieldnames=fieldnames) |
|
|
|
|
|
writer.writeheader() |
|
|
for row in data: |
|
|
|
|
|
writer.writerow({ |
|
|
"content_path": row["content_path"], |
|
|
"frame_seq": str(row["frame_seq"]), |
|
|
"label": row["label"] |
|
|
}) |
|
|
|
|
|
print(f"CSV saved at: {output_csv}") |
|
|
|