(
self,
denoiser: nn.Module,
sampling: Literal["ddpm", "ddim"] = "ddpm",
criterion: Literal["l2", "l1", "huber"] | nn.Module = "l2",
num_training_steps: int = 1000,
objective: Literal["eps", "v", "x0"] = "eps", # loss fitting
prediction: Literal["eps", "v", "x0"] = "eps", # net prediction
beta_schedule: Literal["linear", "cosine", "sigmoid"] = "linear",
min_snr_loss_weight: bool = True,
min_snr_gamma: float = 5.0,
sampling_resolution: tuple[int, int] | None = None,
clip_sample: bool = True,
clip_sample_range: float = 1,
classifier_free_scale: float = 7.5,
use_seg: bool = False,
guidence_step_interval: int = -1,
guidence_weights: tuple = None,
use_guidence_net: bool = False,
use_control_net: bool = False,
upsampling: bool = False,
up_rate=2,
base_up_rate=0.25,
downsampling: bool = False,
down_rate=0.5,
base_down_rate=1.0,
interpolate_rate=0.5,
inference=False
)
| 14 | """ |
| 15 | |
| 16 | def __init__( |
| 17 | self, |
| 18 | denoiser: nn.Module, |
| 19 | sampling: Literal["ddpm", "ddim"] = "ddpm", |
| 20 | criterion: Literal["l2", "l1", "huber"] | nn.Module = "l2", |
| 21 | num_training_steps: int = 1000, |
| 22 | objective: Literal["eps", "v", "x0"] = "eps", # loss fitting |
| 23 | prediction: Literal["eps", "v", "x0"] = "eps", # net prediction |
| 24 | beta_schedule: Literal["linear", "cosine", "sigmoid"] = "linear", |
| 25 | min_snr_loss_weight: bool = True, |
| 26 | min_snr_gamma: float = 5.0, |
| 27 | sampling_resolution: tuple[int, int] | None = None, |
| 28 | clip_sample: bool = True, |
| 29 | clip_sample_range: float = 1, |
| 30 | classifier_free_scale: float = 7.5, |
| 31 | use_seg: bool = False, |
| 32 | guidence_step_interval: int = -1, |
| 33 | guidence_weights: tuple = None, |
| 34 | use_guidence_net: bool = False, |
| 35 | use_control_net: bool = False, |
| 36 | upsampling: bool = False, |
| 37 | up_rate=2, |
| 38 | base_up_rate=0.25, |
| 39 | downsampling: bool = False, |
| 40 | down_rate=0.5, |
| 41 | base_down_rate=1.0, |
| 42 | interpolate_rate=0.5, |
| 43 | inference=False |
| 44 | ): |
| 45 | super().__init__() |
| 46 | self.denoiser = denoiser |
| 47 | self.sampling = sampling |
| 48 | self.num_training_steps = num_training_steps |
| 49 | self.objective = objective |
| 50 | self.prediction = prediction |
| 51 | self.beta_schedule = beta_schedule |
| 52 | self.min_snr_loss_weight = min_snr_loss_weight |
| 53 | self.min_snr_gamma = min_snr_gamma |
| 54 | self.clip_sample = clip_sample |
| 55 | self.clip_sample_range = clip_sample_range |
| 56 | self.classifier_free_scale = classifier_free_scale |
| 57 | self.use_seg = use_seg |
| 58 | self.use_guidence_net = use_guidence_net |
| 59 | self.use_control_net = use_control_net |
| 60 | self.upsampling = upsampling |
| 61 | self.up_rate = up_rate |
| 62 | self.base_up_rate = base_up_rate |
| 63 | self.downsampling = downsampling |
| 64 | self.down_rate = down_rate |
| 65 | self.base_down_rate = base_down_rate |
| 66 | self.interpolate_rate = interpolate_rate |
| 67 | self.inference = inference |
| 68 | |
| 69 | if (use_guidence_net): |
| 70 | self.guidence_weighter = common.SCRGLossWeight( |
| 71 | step_interval=guidence_step_interval, |
| 72 | weights=guidence_weights |
| 73 | ) |
nothing calls this directly
no test coverage detected