Download src/data/prepare_study_a1.py from thanhhuyvan/Gaze-LIPE: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/thanhhuyvan/Gaze-LIPE/resolve/main/src/data/prepare_study_a1.py
- Command line
-
hf download hf://thanhhuyvan/Gaze-LIPE/src/data/prepare_study_a1.py
-
curl -L -o prepare_study_a1.py https://huggingface.co/thanhhuyvan/Gaze-LIPE/resolve/main/src/data/prepare_study_a1.py
1.25 kB
| import os | |
| import subprocess | |
| import sys | |
| from pathlib import Path | |
| # Add project root to path | |
| sys.path.append(str(Path(__file__).parent.parent)) | |
| participants = [f"p{i:02d}" for i in range(15)] | |
| processed_dir = 'data/processed' | |
| patch_size = 16 | |
| suffix = f"_v{patch_size}" | |
| def run_command(cmd): | |
| print(f"Executing: {' '.join(cmd)}") | |
| subprocess.run(cmd, check=True) | |
| print(f"--- Study A-1 Data Preparation (Resolution: {patch_size}x{patch_size}) ---") | |
| for p in participants: | |
| h5_path = os.path.join(processed_dir, f"{p}{suffix}.h5") | |
| # 1. Preprocess | |
| if not os.path.exists(h5_path): | |
| print(f"\n[1/2] Preprocessing {p}...") | |
| run_command([sys.executable, "src/data/preprocess_mpii.py", "--patch_size", str(patch_size), "--participants", p]) | |
| else: | |
| print(f"\n[1/2] {p}{suffix}.h5 already exists. Skipping preprocessing.") | |
| # 2. Teacher Labels | |
| # We check if labels are already in the file by attempting to read them (simplified check: always run if file exists) | |
| print(f"[2/2] Generating teacher labels for {p}{suffix}...") | |
| run_command([sys.executable, "src/data/generate_teacher_labels.py", "--participant", f"{p}{suffix}"]) | |
| print("\n--- All 16x16 data prepared with teacher labels! ---") | |