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
|
pass
|
||||||
|
|
||||||
if cmd_switches and arg_switches and name=='__dict__':
|
if cmd_switches and arg_switches and name=='__dict__':
|
||||||
a = arg_switches.__dict__
|
return self._merge_dict(
|
||||||
a.update(cmd_switches.__dict__)
|
arg_switches.__dict__,
|
||||||
return a
|
cmd_switches.__dict__,
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
return object.__getattribute__(self,name)
|
return object.__getattribute__(self,name)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@ -218,10 +218,7 @@ class Args(object):
|
|||||||
# funny because of their push/pull relationship. This is how to handle it.
|
# funny because of their push/pull relationship. This is how to handle it.
|
||||||
if name=='grid':
|
if name=='grid':
|
||||||
return not cmd_switches.individual and value_arg # arg supersedes cmd
|
return not cmd_switches.individual and value_arg # arg supersedes cmd
|
||||||
if value_cmd is not None:
|
return value_cmd if value_cmd is not None else value_arg
|
||||||
return value_cmd
|
|
||||||
else:
|
|
||||||
return value_arg
|
|
||||||
|
|
||||||
def __setattr__(self,name,value):
|
def __setattr__(self,name,value):
|
||||||
if name.startswith('_'):
|
if name.startswith('_'):
|
||||||
@ -229,6 +226,14 @@ class Args(object):
|
|||||||
else:
|
else:
|
||||||
self._cmd_switches.__dict__[name] = value
|
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):
|
def _create_arg_parser(self):
|
||||||
'''
|
'''
|
||||||
This defines all the arguments used on the command line when you launch
|
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
|
# saves image named _image_ to outdir/name, writing metadata from prompt
|
||||||
# returns full path of output
|
# returns full path of output
|
||||||
def save_image_and_prompt_to_png(self, image, dream_prompt, name, metadata=None):
|
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)
|
path = os.path.join(self.outdir, name)
|
||||||
info = PngImagePlugin.PngInfo()
|
info = PngImagePlugin.PngInfo()
|
||||||
info.add_text('Dream', dream_prompt)
|
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
|
): # in case a stored prompt still contains the !dream command
|
||||||
command.replace('!dream','',1)
|
command.replace('!dream','',1)
|
||||||
|
|
||||||
try:
|
if opt.parse_cmd(command) is None:
|
||||||
parser = opt.parse_cmd(command)
|
|
||||||
except SystemExit:
|
|
||||||
parser.print_help()
|
|
||||||
continue
|
continue
|
||||||
if len(opt.prompt) == 0:
|
if len(opt.prompt) == 0:
|
||||||
print('\nTry again with a prompt!')
|
print('\nTry again with a prompt!')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user