added seamless tiling mode and commands

This commit is contained in:
prixt
2022-09-03 15:13:31 +09:00
parent 33936430d0
commit d922b53c26
2 changed files with 35 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import sys
import copy
import warnings
import time
import torch.nn as nn
from ldm.dream.devices import choose_torch_device
import ldm.dream.readline
from ldm.dream.pngwriter import PngWriter, PromptFormatter
@ -60,6 +61,7 @@ def main():
grid = opt.grid,
# this is solely for recreating the prompt
latent_diffusion_weights=opt.laion400m,
seamless=opt.seamless,
embedding_path=opt.embedding_path,
device_type=opt.device
)
@ -92,6 +94,14 @@ def main():
f'>> model loaded in', '%4.2fs' % (time.time() - tic)
)
for m in t2i.model.modules():
if isinstance(m, (nn.Conv2d, nn.ConvTranspose2d)):
m._orig_padding_mode = m.padding_mode
if opt.seamless:
m.padding_mode = 'circular'
if opt.seamless:
print(">> changed to seamless tiling mode")
if not infile:
print(
"\n* Initialization done! Awaiting your command (-h for help, 'q' to quit)"
@ -374,6 +384,11 @@ def create_argv_parser():
default='outputs/img-samples',
help='Directory to save generated images and a log of prompts and seeds. Default: outputs/img-samples',
)
parser.add_argument(
'--seamless',
action='store_true',
help='Change the model to seamless tiling (circular) mode',
)
parser.add_argument(
'--embedding_path',
type=str,
@ -474,6 +489,11 @@ def create_cmd_parser():
default=None,
help='Directory to save generated images and a log of prompts and seeds',
)
parser.add_argument(
'--seamless',
action='store_true',
help='Change the model to seamless tiling (circular) mode',
)
parser.add_argument(
'-i',
'--individual',