Spaces:
Running on Zero
Running on Zero
File size: 3,852 Bytes
c8ff942 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | from dataclasses import dataclass, field
from typing import Any, Dict, List
from src.enums import Model_Type, Scheduler_Type
@dataclass
class LEDITSConfig:
inversion_skip: float = 0.2
edit_threshold: float = 0.6
edit_friendly: bool = False
@classmethod
def from_yaml(cls, config):
return cls(**config)
def __post_init__(self):
pass
@dataclass
class RFInversionConfig:
gamma: float = 0.5
reconstruction_eta: float = 0.9
editing_eta: float = 0.9
reconstruction_start_timestep: float = 0.0
reconstruction_stop_timestep: float = 0.0
editing_start_timestep: float = 0.0
editing_stop_timestep: float = 0.0
nudge_factor: float = 1.0
@classmethod
def from_yaml(cls, config):
return cls(**config)
def __post_init__(self):
pass
@dataclass
class RenoiseConfig:
max_num_renoise_steps_first_step: int = 5
num_renoise_steps: int = 9
renoise_first_step_max_timestep: int = 250
inversion_max_step: float = 1.0
# Average Parameters
average_latent_estimations: bool = True
average_first_step_range: tuple = (0, 5)
average_step_range: tuple = (8, 10)
# Noise Regularization
noise_regularization_lambda_ac: float = 20.0
noise_regularization_lambda_kl: float = 0.065
noise_regularization_num_reg_steps: int = 4
noise_regularization_num_ac_rolls: int = 5
# Noise Correction
perform_noise_correction: bool = True
@classmethod
def from_yaml(cls, config):
return cls(**config)
def __post_init__(self):
pass
@dataclass
class RunConfig:
method: str = "ddim_inversion"
use_wandb: bool = False
model_type : Model_Type = Model_Type.SDXL
scheduler_type : Scheduler_Type = Scheduler_Type.DDIM
seed: int = 7865
num_inference_steps: int = 50
num_inference_steps_random_image: int = 50
num_inversion_steps: int = 50
inversion_max_step: float = 1.0
inversion_guidance_scale: float = 1.0
guidance_scale: float = 1.0
use_cfgpp_inference: bool = False
use_cfgpp_inversion: bool = False
reconstruction_guidance_scale: float = 1.0
random_image_guidance_scale: float = 1.0
perform_inversion: bool = True
inversion_use_ipa: bool = False
inference_use_ipa: bool = False
inference_ipa_scale: float = 0.3
inversion_ipa_scale: float = 0.3
saturation_removal_ipa_scale: float = 0.3
num_gd_steps: int = 0
gd_step_size: float = 0.0
optimization_start: int = 0
normalize: bool = False
random_inference_times: int = 1
negative_prompt: str = None
remove_cfg_saturation: bool = False
renoise: bool = False
renoise_config: RenoiseConfig = None
use_empty_inversion_prompt: bool = False
use_description_as_negative_prompt: bool = False
rf_config: RFInversionConfig = None
ledits_config: LEDITSConfig = None
guidance_rescale: float = 0.0
sharpening_factor: float = 0.0
use_image_embeds_for_null_prompt: bool = False
use_float32: bool = False
override_edit_prompts: List[str] = None
vae_encode_decode_test: bool = False
quantize: bool = False
@classmethod
def from_yaml(cls, config):
config['model_type'] = Model_Type[config['model_type']]
config['scheduler_type'] = Scheduler_Type[config['scheduler_type']]
if 'renoise_config' in config:
config['renoise_config'] = RenoiseConfig.from_yaml(config['renoise_config'])
if 'rf_config' in config:
config['rf_config'] = RFInversionConfig.from_yaml(config['rf_config'])
if 'ledits_config' in config:
config['ledits_config'] = LEDITSConfig.from_yaml(config['ledits_config'])
return cls(**config)
def __post_init__(self):
pass
|