mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix crash on second prompt #636
This commit is contained in:
parent
994c6b7512
commit
b89aadb3c9
@ -190,10 +190,10 @@ class Args(object):
|
||||
pass
|
||||
|
||||
if cmd_switches and arg_switches and name=='__dict__':
|
||||
a = arg_switches.__dict__
|
||||
a.update(cmd_switches.__dict__)
|
||||
return a
|
||||
|
||||
return self._merge_dict(
|
||||
arg_switches.__dict__,
|
||||
cmd_switches.__dict__,
|
||||
)
|
||||
try:
|
||||
return object.__getattribute__(self,name)
|
||||
except AttributeError:
|
||||
@ -218,10 +218,7 @@ class Args(object):
|
||||
# funny because of their push/pull relationship. This is how to handle it.
|
||||
if name=='grid':
|
||||
return not cmd_switches.individual and value_arg # arg supersedes cmd
|
||||
if value_cmd is not None:
|
||||
return value_cmd
|
||||
else:
|
||||
return value_arg
|
||||
return value_cmd if value_cmd is not None else value_arg
|
||||
|
||||
def __setattr__(self,name,value):
|
||||
if name.startswith('_'):
|
||||
@ -229,6 +226,14 @@ class Args(object):
|
||||
else:
|
||||
self._cmd_switches.__dict__[name] = value
|
||||
|
||||
def _merge_dict(self,dict1,dict2):
|
||||
new_dict = {}
|
||||
for k in set(list(dict1.keys())+list(dict2.keys())):
|
||||
value1 = dict1.get(k,None)
|
||||
value2 = dict2.get(k,None)
|
||||
new_dict[k] = value2 if value2 is not None else value1
|
||||
return new_dict
|
||||
|
||||
def _create_arg_parser(self):
|
||||
'''
|
||||
This defines all the arguments used on the command line when you launch
|
||||
|
@ -34,7 +34,6 @@ class PngWriter:
|
||||
# saves image named _image_ to outdir/name, writing metadata from prompt
|
||||
# returns full path of output
|
||||
def save_image_and_prompt_to_png(self, image, dream_prompt, name, metadata=None):
|
||||
print(f'self.outdir={self.outdir}, name={name}')
|
||||
path = os.path.join(self.outdir, name)
|
||||
info = PngImagePlugin.PngInfo()
|
||||
info.add_text('Dream', dream_prompt)
|
||||
|
@ -132,10 +132,7 @@ def main_loop(gen, opt, infile):
|
||||
): # in case a stored prompt still contains the !dream command
|
||||
command.replace('!dream','',1)
|
||||
|
||||
try:
|
||||
parser = opt.parse_cmd(command)
|
||||
except SystemExit:
|
||||
parser.print_help()
|
||||
if opt.parse_cmd(command) is None:
|
||||
continue
|
||||
if len(opt.prompt) == 0:
|
||||
print('\nTry again with a prompt!')
|
||||
|
Loading…
Reference in New Issue
Block a user