Download fcdm_diffae/config.py from data-archetype/semdisdiffae: direct link, hf CLI and curl.
- Browser
- Download file 2.15 kB
-
https://huggingface.co/data-archetype/semdisdiffae/resolve/main/fcdm_diffae/config.py
- Command line
-
hf download hf://data-archetype/semdisdiffae/fcdm_diffae/config.py
-
curl -L -o config.py https://huggingface.co/data-archetype/semdisdiffae/resolve/main/fcdm_diffae/config.py
2.15 kB
| """Frozen model architecture and user-tunable inference configuration.""" | |
| from __future__ import annotations | |
| import json | |
| from dataclasses import asdict, dataclass | |
| from pathlib import Path | |
| class FCDMDiffAEConfig: | |
| """Frozen model architecture config. Stored alongside weights as config.json.""" | |
| in_channels: int = 3 | |
| patch_size: int = 16 | |
| model_dim: int = 896 | |
| encoder_depth: int = 4 | |
| decoder_depth: int = 8 | |
| decoder_start_blocks: int = 2 | |
| decoder_end_blocks: int = 2 | |
| bottleneck_dim: int = 128 | |
| mlp_ratio: float = 4.0 | |
| depthwise_kernel_size: int = 7 | |
| adaln_low_rank_rank: int = 128 | |
| # Encoder posterior kind: "diagonal_gaussian" or "deterministic" | |
| bottleneck_posterior_kind: str = "diagonal_gaussian" | |
| # Post-bottleneck normalization: "channel_wise" or "disabled" | |
| bottleneck_norm_mode: str = "disabled" | |
| # VP diffusion schedule endpoints | |
| logsnr_min: float = -10.0 | |
| logsnr_max: float = 10.0 | |
| # Pixel-space noise std for VP diffusion initialization | |
| pixel_noise_std: float = 0.558 | |
| def save(self, path: str | Path) -> None: | |
| """Save config as JSON.""" | |
| p = Path(path) | |
| p.parent.mkdir(parents=True, exist_ok=True) | |
| p.write_text(json.dumps(asdict(self), indent=2) + "\n") | |
| def load(cls, path: str | Path) -> FCDMDiffAEConfig: | |
| """Load config from JSON.""" | |
| data = json.loads(Path(path).read_text()) | |
| return cls(**data) | |
| class FCDMDiffAEInferenceConfig: | |
| """User-tunable inference parameters with sensible defaults. | |
| PDG (Path-Drop Guidance) sharpens reconstructions by degrading conditioning | |
| in one pass and amplifying the difference. When enabled, uses 2 NFE per step. | |
| Recommended: ``pdg=True, pdg_strength=2.0, num_steps=10``. | |
| """ | |
| num_steps: int = 1 # number of denoising steps (NFE) | |
| sampler: str = "ddim" # "ddim" or "dpmpp_2m" | |
| schedule: str = "linear" # "linear" or "cosine" | |
| pdg: bool = False # enable PDG for perceptual sharpening | |
| pdg_strength: float = 2.0 # CFG-like strength when pdg=True | |
| seed: int | None = None | |