Added experimental band loss
This commit is contained in:
1 parent
7045370346
commit
831ccfa7aa
4 files changed
+160
-2
No files matched your search
@@ -36,7 +36,7 @@ from diffusers import EMAModel
|
||||
import math
|
||||
from toolkit.train_tools import precondition_model_outputs_flow_match
|
||||
from toolkit.models.diffusion_feature_extraction import DiffusionFeatureExtractor, load_dfe
|
||||
from toolkit.util.losses import wavelet_loss, stepped_loss
|
||||
from toolkit.util.losses import wavelet_loss, stepped_loss, band_loss
|
||||
import torch.nn.functional as F
|
||||
from toolkit.unloader import unload_text_encoder
|
||||
from PIL import Image
|
||||
@@ -952,6 +952,9 @@ class SDTrainer(BaseSDTrainProcess):
|
||||
loss = torch.nn.functional.l1_loss(pred.float(), target.float(), reduction="none")
|
||||
elif self.train_config.loss_type == "wavelet":
|
||||
loss = wavelet_loss(pred, batch.latents, noise)
|
||||
elif self.train_config.loss_type == "band":
|
||||
# per-sample frequency-weighted MSE: bands the noise has buried at this t drop out
|
||||
loss = band_loss(pred, target, batch.latents, noise, timesteps, self.sd.is_flow_matching, self.sd.noise_scheduler)
|
||||
elif self.train_config.loss_type == "stepped":
|
||||
loss = stepped_loss(pred, batch.latents, noise, noisy_latents, timesteps, self.sd.noise_scheduler)
|
||||
# the way this loss works, it is low, increase it to match predictable LR effects
|
||||
|
||||
Reference in new issue
Block a user