| from __future__ import annotations |
|
|
| from pathlib import Path |
|
|
| import numpy as np |
| import pandas as pd |
| import yaml |
|
|
| from fall.train import train_one |
|
|
|
|
| def main() -> None: |
| root = Path("outputs/smoke") |
| pose_dir = root / "poses" |
| pose_dir.mkdir(parents=True, exist_ok=True) |
| rows = [] |
| rng = np.random.default_rng(42) |
| for i in range(24): |
| label = int(i % 2 == 0) |
| pose = rng.normal(0, 1, size=(32, 17, 3)).astype(np.float32) |
| pose[..., 2] = 0.95 |
| if label: |
| pose[:, :, 1] += np.linspace(0, 3, 32)[:, None] |
| path = pose_dir / f"sample_{i:03d}.npy" |
| np.save(path, pose) |
| split = "train" if i < 16 else "val" if i < 20 else "test" |
| rows.append({"video_id": f"sample_{i:03d}", "video_path": "synthetic", "pose_path": str(path), "label": label, "dataset": "synthetic", "split": split}) |
| manifest = root / "manifest.csv" |
| pd.DataFrame(rows).to_csv(manifest, index=False) |
| cfg = { |
| "seed": 42, |
| "device": "cuda", |
| "output_dir": str(root / "run"), |
| "data": {"type": "pose", "manifest": str(manifest), "frames": 32, "use_confidence": True, "use_velocity": True}, |
| "model": {"name": "pose_tcn_attention", "hidden_dim": 32, "layers": 2, "dropout": 0.1}, |
| "train": {"epochs": 2, "batch_size": 8, "eval_batch_size": 8, "num_workers": 0, "lr": 0.001, "class_weight": True, "amp": True, "patience": 2}, |
| } |
| cfg_path = root / "config.yaml" |
| with cfg_path.open("w", encoding="utf-8") as f: |
| yaml.safe_dump(cfg, f) |
| print(train_one(cfg_path)) |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|