Spaces:
Runtime error
Runtime error
Upload config.py
Browse files
config.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dataclasses import dataclass, field
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from typing import Dict, List
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
@dataclass
|
| 7 |
+
class RunConfig:
|
| 8 |
+
# Guiding text prompt
|
| 9 |
+
prompt: str = "<task-prompt>"
|
| 10 |
+
# Whether to use Stable Diffusion v2.1
|
| 11 |
+
sd_2_1: bool = False
|
| 12 |
+
# Which token indices to alter with attend-and-excite
|
| 13 |
+
token_indices: List[int] = field(default_factory=lambda: [2,5])
|
| 14 |
+
# Which random seeds to use when generating
|
| 15 |
+
seeds: List[int] = field(default_factory=lambda: [42])
|
| 16 |
+
# Path to save all outputs to
|
| 17 |
+
output_path: Path = Path('./outputs')
|
| 18 |
+
# Number of denoising steps
|
| 19 |
+
n_inference_steps: int = 50
|
| 20 |
+
# Text guidance scale
|
| 21 |
+
guidance_scale: float = 7.5
|
| 22 |
+
# Number of denoising steps to apply attend-and-excite
|
| 23 |
+
max_iter_to_alter: int = 25
|
| 24 |
+
# Resolution of UNet to compute attention maps over
|
| 25 |
+
attention_res: int = 16
|
| 26 |
+
# Whether to run standard SD or attend-and-excite
|
| 27 |
+
run_standard_sd: bool = False
|
| 28 |
+
# Dictionary defining the iterations and desired thresholds to apply iterative latent refinement in
|
| 29 |
+
thresholds: Dict[int, float] = field(default_factory=lambda: {0: 0.05, 10: 0.5, 20: 0.8})
|
| 30 |
+
# Scale factor for updating the denoised latent z_t
|
| 31 |
+
scale_factor: int = 20
|
| 32 |
+
# Start and end values used for scaling the scale factor - decays linearly with the denoising timestep
|
| 33 |
+
scale_range: tuple = field(default_factory=lambda: (1.0, 0.5))
|
| 34 |
+
# Whether to apply the Gaussian smoothing before computing the maximum attention value for each subject token
|
| 35 |
+
smooth_attentions: bool = True
|
| 36 |
+
# Standard deviation for the Gaussian smoothing
|
| 37 |
+
sigma: float = 0.5
|
| 38 |
+
# Kernel size for the Gaussian smoothing
|
| 39 |
+
kernel_size: int = 3
|
| 40 |
+
# Whether to save cross attention maps for the final results
|
| 41 |
+
save_cross_attention_maps: bool = False
|
| 42 |
+
|
| 43 |
+
def __post_init__(self):
|
| 44 |
+
self.output_path.mkdir(exist_ok=True, parents=True)
|