Spaces:
Running
Running
File size: 3,523 Bytes
1ac3d64 | 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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | """
Diagnose data directory structure and list file format
"""
import os
def check_data_structure():
data_dir = r"C:\Users\vinip\Desktop\TALL4Deepfake\data"
list_file = r"C:\Users\vinip\Desktop\TALL4Deepfake\lists\cdf_test_fold.txt"
print("=" * 60)
print("Data Structure Diagnostic")
print("=" * 60)
# Check data directory
print(f"\n1. Checking data directory: {data_dir}")
if os.path.exists(data_dir):
print(" ✓ Directory exists")
# List subdirectories
subdirs = [d for d in os.listdir(data_dir) if os.path.isdir(os.path.join(data_dir, d))]
print(f"\n Subdirectories found: {subdirs}")
# Check a few subdirs
for subdir in subdirs[:3]:
subdir_path = os.path.join(data_dir, subdir)
video_folders = os.listdir(subdir_path)[:3]
print(f"\n {subdir}/ contains: {video_folders}")
# Check first video folder
if video_folders:
first_video = os.path.join(subdir_path, video_folders[0])
if os.path.isdir(first_video):
frames = os.listdir(first_video)[:5]
print(f" {video_folders[0]}/ contains: {frames}")
else:
print(" ✗ Directory not found!")
return
# Check list file
print(f"\n2. Checking list file: {list_file}")
if os.path.exists(list_file):
print(" ✓ File exists")
with open(list_file, 'r') as f:
lines = f.readlines()
print(f" Total lines: {len(lines)}")
print("\n First 5 lines:")
for i, line in enumerate(lines[:5], 1):
print(f" {i}: {repr(line.strip())}")
# Analyze path format
print("\n3. Path format analysis:")
first_line = lines[0].strip()
parts = first_line.split()
if parts:
video_path = parts[0]
print(f" Video path: {repr(video_path)}")
print(f" Uses forward slashes: {'/' in video_path}")
print(f" Uses backslashes: {chr(92) in video_path}")
# Try to construct full path
full_path = os.path.join(data_dir, video_path)
print(f"\n Constructed path: {full_path}")
print(f" Path exists: {os.path.exists(full_path)}")
# Try with normalization
normalized = os.path.normpath(os.path.join(data_dir, video_path))
print(f"\n Normalized path: {normalized}")
print(f" Path exists: {os.path.exists(normalized)}")
# Check if video folder exists
if not os.path.exists(normalized):
# Try to find similar paths
print("\n ⚠ Path doesn't exist. Looking for similar paths...")
video_name = os.path.basename(video_path)
category = os.path.dirname(video_path).replace('/', os.sep).replace('\\', os.sep)
category_path = os.path.join(data_dir, category)
if os.path.exists(category_path):
contents = os.listdir(category_path)
print(f"\n Directory '{category}' contains: {contents[:10]}")
else:
print(" ✗ File not found!")
print("\n" + "=" * 60)
if __name__ == "__main__":
check_data_structure() |