ZhenYe234 commited on
Commit
3c41e88
·
verified ·
1 Parent(s): e839d6e

Upload scripts/validate_clean_metadata.py

Browse files
Files changed (1) hide show
  1. scripts/validate_clean_metadata.py +46 -0
scripts/validate_clean_metadata.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import csv
3
+ import os
4
+ import time
5
+ from collections import Counter
6
+ from pathlib import Path
7
+
8
+ root = Path('/aifs4su/yezhen/data/Talker-T2AV-Data-clean')
9
+ csv_path = root / 'metadata' / 'train.csv'
10
+ report_path = root / 'validation_report.txt'
11
+ cols = ['wav_path', 'motion_pt_path', 'video_path']
12
+ rows = 0
13
+ missing = Counter()
14
+ sources = Counter()
15
+ start = time.time()
16
+ examples = []
17
+ old_name_rows = 0
18
+
19
+ with csv_path.open('r', newline='', encoding='utf-8') as f:
20
+ reader = csv.DictReader(f)
21
+ for row in reader:
22
+ rows += 1
23
+ sources[row.get('dataset_source', '')] += 1
24
+ if any('seamless_emilia' in row.get(k, '') for k in row.keys()):
25
+ old_name_rows += 1
26
+ for col in cols:
27
+ rel = row.get(col, '')
28
+ if rel and not (root / rel).exists():
29
+ missing[col] += 1
30
+ if len(examples) < 20:
31
+ examples.append((rows, col, rel))
32
+ if rows % 10000 == 0:
33
+ print(f'validated={rows} elapsed={time.time()-start:.1f}s missing={dict(missing)} old_name_rows={old_name_rows}', flush=True)
34
+
35
+ elapsed = time.time() - start
36
+ with report_path.open('w', encoding='utf-8') as out:
37
+ out.write(f'rows={rows}\n')
38
+ out.write(f'sources={dict(sources)}\n')
39
+ out.write(f'missing={dict(missing)}\n')
40
+ out.write(f'old_name_rows={old_name_rows}\n')
41
+ out.write(f'elapsed_sec={elapsed:.1f}\n')
42
+ for ex in examples:
43
+ out.write(f'missing_example={ex}\n')
44
+ print(f'DONE rows={rows} missing={dict(missing)} old_name_rows={old_name_rows} elapsed={elapsed:.1f}s report={report_path}', flush=True)
45
+ if missing or old_name_rows:
46
+ raise SystemExit(2)