Upload v2/config.py with huggingface_hub
Browse files- v2/config.py +62 -0
v2/config.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from dataclasses import dataclass
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
@dataclass(frozen=True)
|
| 8 |
+
class WorkflowConfig:
|
| 9 |
+
preset: str = "quality"
|
| 10 |
+
remove_background: bool = True
|
| 11 |
+
shape_steps: int = 30
|
| 12 |
+
shape_guidance: float = 7.5
|
| 13 |
+
shape_face_count: int = 120000
|
| 14 |
+
texture_variant: str = "sdxl"
|
| 15 |
+
enhance_face_texture: bool = True
|
| 16 |
+
rembg_threshold: float = 0.5
|
| 17 |
+
rembg_erode: int = 2
|
| 18 |
+
export_fbx: bool = False
|
| 19 |
+
pshuman_weight_threshold: float = 0.5
|
| 20 |
+
pshuman_retract_mm: float = 2.0
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
PRESETS: dict[str, WorkflowConfig] = {
|
| 24 |
+
"preview": WorkflowConfig(
|
| 25 |
+
preset="preview",
|
| 26 |
+
shape_steps=18,
|
| 27 |
+
shape_guidance=6.0,
|
| 28 |
+
shape_face_count=60000,
|
| 29 |
+
enhance_face_texture=False,
|
| 30 |
+
),
|
| 31 |
+
"quality": WorkflowConfig(
|
| 32 |
+
preset="quality",
|
| 33 |
+
shape_steps=30,
|
| 34 |
+
shape_guidance=7.5,
|
| 35 |
+
shape_face_count=120000,
|
| 36 |
+
enhance_face_texture=True,
|
| 37 |
+
),
|
| 38 |
+
"cinematic": WorkflowConfig(
|
| 39 |
+
preset="cinematic",
|
| 40 |
+
shape_steps=45,
|
| 41 |
+
shape_guidance=8.5,
|
| 42 |
+
shape_face_count=200000,
|
| 43 |
+
enhance_face_texture=True,
|
| 44 |
+
pshuman_weight_threshold=0.45,
|
| 45 |
+
pshuman_retract_mm=1.0,
|
| 46 |
+
),
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def get_preset(name: str) -> WorkflowConfig:
|
| 51 |
+
if name not in PRESETS:
|
| 52 |
+
valid = ", ".join(sorted(PRESETS))
|
| 53 |
+
raise ValueError(f"Unknown preset '{name}'. Valid presets: {valid}")
|
| 54 |
+
return PRESETS[name]
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def ensure_job_dirs(output_dir: Path) -> tuple[Path, Path]:
|
| 58 |
+
artifacts = output_dir / "artifacts"
|
| 59 |
+
logs = output_dir / "logs"
|
| 60 |
+
artifacts.mkdir(parents=True, exist_ok=True)
|
| 61 |
+
logs.mkdir(parents=True, exist_ok=True)
|
| 62 |
+
return artifacts, logs
|