Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 39 additions & 12 deletions ldm/simplet2i.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,25 @@ def __init__(self,
self.seed = seed

@torch.no_grad()
def txt2img(self,prompt,outdir=None,batch_size=None,iterations=None,
steps=None,seed=None,grid=None,individual=None,width=None,height=None,
cfg_scale=None,ddim_eta=None,strength=None,embedding_path=None,init_img=None,
skip_normalize=False,variants=None): # note the "variants" option is an unused hack caused by how options are passed
def txt2img(
self,
prompt,
outdir=None,
batch_size=None,
iterations=None,
steps=None,
seed=None,
grid=None,
individual=None,
width=None,
height=None,
cfg_scale=None,
ddim_eta=None,
strength=None,
embedding_path=None,
init_img=None,
skip_normalize=False,
):
"""
Generate an image from the prompt, writing iteration images into the outdir
The output is a list of lists in the format: [[filename1,seed1], [filename2,seed2],...]
Expand All @@ -172,7 +187,7 @@ def txt2img(self,prompt,outdir=None,batch_size=None,iterations=None,
ddim_eta = ddim_eta or self.ddim_eta
batch_size = batch_size or self.batch_size
iterations = iterations or self.iterations
strength = strength or self.strength # not actually used here, but preserved for code refactoring
strength = strength or self.strength # not actually used here, but preserved for code refactoring
embedding_path = embedding_path or self.embedding_path

model = self.load_model() # will instantiate the model or return it from cache
Expand Down Expand Up @@ -271,9 +286,6 @@ def txt2img(self,prompt,outdir=None,batch_size=None,iterations=None,
batch_size=batch_size,
iterations=iterations,
outdir=outdir)
except KeyboardInterrupt:
print('*interrupted*')
print('Partial results will be returned; if --grid was requested, nothing will be returned.')
except RuntimeError as e:
print(str(e))

Expand All @@ -284,10 +296,25 @@ def txt2img(self,prompt,outdir=None,batch_size=None,iterations=None,

# There is lots of shared code between this and txt2img and should be refactored.
@torch.no_grad()
def img2img(self,prompt,outdir=None,init_img=None,batch_size=None,iterations=None,
steps=None,seed=None,grid=None,individual=None,width=None,height=None,
cfg_scale=None,ddim_eta=None,strength=None,embedding_path=None,
skip_normalize=False,variants=None): # note the "variants" option is an unused hack caused by how options are passed
def img2img(
self,
prompt,
outdir=None,
init_img=None,
batch_size=None,
iterations=None,
steps=None,
seed=None,
grid=None,
individual=None,
width=None,
height=None,
cfg_scale=None,
ddim_eta=None,
strength=None,
embedding_path=None,
skip_normalize=False,
):
"""
Generate an image from the prompt and the initial image, writing iteration images into the outdir
The output is a list of lists in the format: [[filename1,seed1], [filename2,seed2],...]
Expand Down
Loading