forked from AUTOMATIC1111/stable-diffusion-webui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'AUTOMATIC1111:dev' into dev
- Loading branch information
Showing
71 changed files
with
1,746 additions
and
524 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
model: | ||
base_learning_rate: 1.0e-04 | ||
target: ldm.models.diffusion.ddpm.LatentDiffusion | ||
params: | ||
linear_start: 0.00085 | ||
linear_end: 0.0120 | ||
num_timesteps_cond: 1 | ||
log_every_t: 200 | ||
timesteps: 1000 | ||
first_stage_key: "jpg" | ||
cond_stage_key: "txt" | ||
image_size: 64 | ||
channels: 4 | ||
cond_stage_trainable: false # Note: different from the one we trained before | ||
conditioning_key: crossattn | ||
monitor: val/loss_simple_ema | ||
scale_factor: 0.18215 | ||
use_ema: False | ||
|
||
scheduler_config: # 10000 warmup steps | ||
target: ldm.lr_scheduler.LambdaLinearScheduler | ||
params: | ||
warm_up_steps: [ 10000 ] | ||
cycle_lengths: [ 10000000000000 ] # incredibly large number to prevent corner cases | ||
f_start: [ 1.e-6 ] | ||
f_max: [ 1. ] | ||
f_min: [ 1. ] | ||
|
||
unet_config: | ||
target: ldm.modules.diffusionmodules.openaimodel.UNetModel | ||
params: | ||
image_size: 32 # unused | ||
in_channels: 4 | ||
out_channels: 4 | ||
model_channels: 320 | ||
attention_resolutions: [ 4, 2, 1 ] | ||
num_res_blocks: 2 | ||
channel_mult: [ 1, 2, 4, 4 ] | ||
num_head_channels: 64 | ||
use_spatial_transformer: True | ||
use_linear_in_transformer: True | ||
transformer_depth: 1 | ||
context_dim: 1024 | ||
use_checkpoint: True | ||
legacy: False | ||
|
||
first_stage_config: | ||
target: ldm.models.autoencoder.AutoencoderKL | ||
params: | ||
embed_dim: 4 | ||
monitor: val/rec_loss | ||
ddconfig: | ||
double_z: true | ||
z_channels: 4 | ||
resolution: 256 | ||
in_channels: 3 | ||
out_ch: 3 | ||
ch: 128 | ||
ch_mult: | ||
- 1 | ||
- 2 | ||
- 4 | ||
- 4 | ||
num_res_blocks: 2 | ||
attn_resolutions: [] | ||
dropout: 0.0 | ||
lossconfig: | ||
target: torch.nn.Identity | ||
|
||
cond_stage_config: | ||
target: modules.xlmr_m18.BertSeriesModelWithTransformation | ||
params: | ||
name: "XLMR-Large" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import sys | ||
import copy | ||
import logging | ||
|
||
|
||
class ColoredFormatter(logging.Formatter): | ||
COLORS = { | ||
"DEBUG": "\033[0;36m", # CYAN | ||
"INFO": "\033[0;32m", # GREEN | ||
"WARNING": "\033[0;33m", # YELLOW | ||
"ERROR": "\033[0;31m", # RED | ||
"CRITICAL": "\033[0;37;41m", # WHITE ON RED | ||
"RESET": "\033[0m", # RESET COLOR | ||
} | ||
|
||
def format(self, record): | ||
colored_record = copy.copy(record) | ||
levelname = colored_record.levelname | ||
seq = self.COLORS.get(levelname, self.COLORS["RESET"]) | ||
colored_record.levelname = f"{seq}{levelname}{self.COLORS['RESET']}" | ||
return super().format(colored_record) | ||
|
||
|
||
logger = logging.getLogger("lora") | ||
logger.propagate = False | ||
|
||
|
||
if not logger.handlers: | ||
handler = logging.StreamHandler(sys.stdout) | ||
handler.setFormatter( | ||
ColoredFormatter("[%(name)s]-%(levelname)s: %(message)s") | ||
) | ||
logger.addHandler(handler) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
import network | ||
|
||
class ModuleTypeGLora(network.ModuleType): | ||
def create_module(self, net: network.Network, weights: network.NetworkWeights): | ||
if all(x in weights.w for x in ["a1.weight", "a2.weight", "alpha", "b1.weight", "b2.weight"]): | ||
return NetworkModuleGLora(net, weights) | ||
|
||
return None | ||
|
||
# adapted from https://github.com/KohakuBlueleaf/LyCORIS | ||
class NetworkModuleGLora(network.NetworkModule): | ||
def __init__(self, net: network.Network, weights: network.NetworkWeights): | ||
super().__init__(net, weights) | ||
|
||
if hasattr(self.sd_module, 'weight'): | ||
self.shape = self.sd_module.weight.shape | ||
|
||
self.w1a = weights.w["a1.weight"] | ||
self.w1b = weights.w["b1.weight"] | ||
self.w2a = weights.w["a2.weight"] | ||
self.w2b = weights.w["b2.weight"] | ||
|
||
def calc_updown(self, orig_weight): | ||
w1a = self.w1a.to(orig_weight.device, dtype=orig_weight.dtype) | ||
w1b = self.w1b.to(orig_weight.device, dtype=orig_weight.dtype) | ||
w2a = self.w2a.to(orig_weight.device, dtype=orig_weight.dtype) | ||
w2b = self.w2b.to(orig_weight.device, dtype=orig_weight.dtype) | ||
|
||
output_shape = [w1a.size(0), w1b.size(1)] | ||
updown = ((w2b @ w1b) + ((orig_weight @ w2a) @ w1a)) | ||
|
||
return self.finalize_updown(updown, orig_weight, output_shape) |
Oops, something went wrong.