File size: 1,457 Bytes
d39b279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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}")