seetrails_aigvdet_v2.0.0 / create_csv.py
Kalpit
feat: Add model files with LFS
d39b279
raw
history blame
1.46 kB
import os
import csv
# Source directories
real_dir = "/home/kalpit/workspace/aigc/data/ShareVeo3/test/0_real"
fake_dir = "/home/kalpit/workspace/aigc/data/ShareVeo3/test/1_fake"
# Output CSV path
output_csv = "/home/kalpit/workspace/aigc/repos/DeMamba/veo_test.csv"
# Function to get all image paths from a directory
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], # list containing the single frame path
"label": label
})
return image_paths
# Collect all images
data = []
data.extend(get_image_paths(real_dir, 0))
data.extend(get_image_paths(fake_dir, 1))
# Write to CSV
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:
# Convert frame_seq list to string as shown in your example
writer.writerow({
"content_path": row["content_path"],
"frame_seq": str(row["frame_seq"]),
"label": row["label"]
})
print(f"CSV saved at: {output_csv}")