mirror of
https://github.com/brycedrennan/imaginAIry
synced 2024-11-05 12:00:15 +00:00
fix: performance improvement. disable ema (#139)
A configuration `use_ema: False` was became necessary in the newer Stable Diffusion code but was missing from the 1.5 config.
This commit is contained in:
parent
ad5e467042
commit
ccf9749df5
4
.gitignore
vendored
4
.gitignore
vendored
@ -21,4 +21,6 @@ gfpgan/**
|
|||||||
tests/vastai_cli.py
|
tests/vastai_cli.py
|
||||||
/tests/test_output_local_cuda/
|
/tests/test_output_local_cuda/
|
||||||
/testing_support/
|
/testing_support/
|
||||||
.unison*
|
.unison*
|
||||||
|
*.kgrind
|
||||||
|
*.pyprof
|
@ -298,3 +298,9 @@ aimg.add_command(imagine_cmd, name="imagine")
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
imagine_cmd() # noqa
|
imagine_cmd() # noqa
|
||||||
|
# from cProfile import Profile
|
||||||
|
# from pyprof2calltree import convert, visualize
|
||||||
|
# profiler = Profile()
|
||||||
|
# profiler.runctx("imagine_cmd.main(standalone_mode=False)", locals(), globals())
|
||||||
|
# convert(profiler.getstats(), 'imagine.kgrind')
|
||||||
|
# visualize(profiler.getstats())
|
||||||
|
@ -16,6 +16,7 @@ model:
|
|||||||
monitor: val/loss_simple_ema
|
monitor: val/loss_simple_ema
|
||||||
scale_factor: 0.18215
|
scale_factor: 0.18215
|
||||||
finetune_keys: null
|
finetune_keys: null
|
||||||
|
use_ema: False
|
||||||
|
|
||||||
scheduler_config: # 10000 warm-up steps
|
scheduler_config: # 10000 warm-up steps
|
||||||
target: ldm.lr_scheduler.LambdaLinearScheduler
|
target: ldm.lr_scheduler.LambdaLinearScheduler
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
model:
|
model:
|
||||||
base_learning_rate: 1.0e-04
|
base_learning_rate: 1.0e-4
|
||||||
target: imaginairy.modules.diffusion.ddpm.LatentDiffusion
|
target: imaginairy.modules.diffusion.ddpm.LatentDiffusion
|
||||||
params:
|
params:
|
||||||
linear_start: 0.00085
|
linear_start: 0.00085
|
||||||
@ -11,10 +11,11 @@ model:
|
|||||||
cond_stage_key: "txt"
|
cond_stage_key: "txt"
|
||||||
image_size: 64
|
image_size: 64
|
||||||
channels: 4
|
channels: 4
|
||||||
cond_stage_trainable: false # Note: different from the one we trained before
|
cond_stage_trainable: false
|
||||||
conditioning_key: crossattn
|
conditioning_key: crossattn
|
||||||
monitor: val/loss_simple_ema
|
monitor: val/loss_simple_ema
|
||||||
scale_factor: 0.18215
|
scale_factor: 0.18215
|
||||||
|
use_ema: False # we set this to false because this is an inference only config
|
||||||
|
|
||||||
scheduler_config: # 10000 warm-up steps
|
scheduler_config: # 10000 warm-up steps
|
||||||
target: imaginairy.lr_scheduler.LambdaLinearScheduler
|
target: imaginairy.lr_scheduler.LambdaLinearScheduler
|
||||||
@ -28,6 +29,7 @@ model:
|
|||||||
unet_config:
|
unet_config:
|
||||||
target: imaginairy.modules.diffusion.openaimodel.UNetModel
|
target: imaginairy.modules.diffusion.openaimodel.UNetModel
|
||||||
params:
|
params:
|
||||||
|
use_checkpoint: True
|
||||||
image_size: 32 # unused
|
image_size: 32 # unused
|
||||||
in_channels: 4
|
in_channels: 4
|
||||||
out_channels: 4
|
out_channels: 4
|
||||||
@ -39,7 +41,6 @@ model:
|
|||||||
use_spatial_transformer: True
|
use_spatial_transformer: True
|
||||||
transformer_depth: 1
|
transformer_depth: 1
|
||||||
context_dim: 768
|
context_dim: 768
|
||||||
use_checkpoint: True
|
|
||||||
legacy: False
|
legacy: False
|
||||||
|
|
||||||
first_stage_config:
|
first_stage_config:
|
||||||
|
@ -80,7 +80,8 @@ def load_model_from_config(config, weights_location):
|
|||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
if e.errno == 2:
|
if e.errno == 2:
|
||||||
logger.error(
|
logger.error(
|
||||||
f'Error: "{ckpt_path}" not a valid path to model weights.\nPreconfigured models you can use: {MODEL_SHORT_NAMES}.')
|
f'Error: "{ckpt_path}" not a valid path to model weights.\nPreconfigured models you can use: {MODEL_SHORT_NAMES}.'
|
||||||
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
raise e
|
raise e
|
||||||
except RuntimeError as e:
|
except RuntimeError as e:
|
||||||
|
@ -449,16 +449,19 @@ class SpatialTransformer(nn.Module):
|
|||||||
b, c, h, w = x.shape # noqa
|
b, c, h, w = x.shape # noqa
|
||||||
x_in = x
|
x_in = x
|
||||||
x = self.norm(x)
|
x = self.norm(x)
|
||||||
if not self.use_linear:
|
|
||||||
x = self.proj_in(x)
|
|
||||||
x = rearrange(x, "b c h w -> b (h w) c").contiguous()
|
|
||||||
if self.use_linear:
|
if self.use_linear:
|
||||||
|
x = rearrange(x, "b c h w -> b (h w) c").contiguous()
|
||||||
x = self.proj_in(x)
|
x = self.proj_in(x)
|
||||||
for i, block in enumerate(self.transformer_blocks):
|
for i, block in enumerate(self.transformer_blocks):
|
||||||
x = block(x, context=context[i])
|
x = block(x, context=context[i])
|
||||||
if self.use_linear:
|
|
||||||
x = self.proj_out(x)
|
x = self.proj_out(x)
|
||||||
x = rearrange(x, "b (h w) c -> b c h w", h=h, w=w).contiguous()
|
x = rearrange(x, "b (h w) c -> b c h w", h=h, w=w).contiguous()
|
||||||
if not self.use_linear:
|
else:
|
||||||
|
x = self.proj_in(x)
|
||||||
|
x = rearrange(x, "b c h w -> b (h w) c")
|
||||||
|
for i, block in enumerate(self.transformer_blocks):
|
||||||
|
x = block(x, context=context[i])
|
||||||
|
x = rearrange(x, "b (h w) c -> b c h w", h=h, w=w)
|
||||||
x = self.proj_out(x)
|
x = self.proj_out(x)
|
||||||
|
|
||||||
return x + x_in
|
return x + x_in
|
||||||
|
Loading…
Reference in New Issue
Block a user