Spaces:
Running
Running
| """ | |
| 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() |