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