mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Keyboard interrupt retains seed and log information in files produced prior to interrupt. Closes #21
This commit is contained in:
parent
bc7b1fdd37
commit
710b908290
@ -186,8 +186,10 @@ The vast majority of these arguments default to reasonable values.
|
|||||||
images = list()
|
images = list()
|
||||||
seeds = list()
|
seeds = list()
|
||||||
filename = None
|
filename = None
|
||||||
|
image_count = 0
|
||||||
tic = time.time()
|
tic = time.time()
|
||||||
|
|
||||||
|
try:
|
||||||
with torch.no_grad():
|
with torch.no_grad():
|
||||||
with precision_scope("cuda"):
|
with precision_scope("cuda"):
|
||||||
with model.ema_scope():
|
with model.ema_scope():
|
||||||
@ -226,7 +228,7 @@ The vast majority of these arguments default to reasonable values.
|
|||||||
else:
|
else:
|
||||||
all_samples.append(x_samples_ddim)
|
all_samples.append(x_samples_ddim)
|
||||||
seeds.append(seed)
|
seeds.append(seed)
|
||||||
|
image_count += 1
|
||||||
seed = self._new_seed()
|
seed = self._new_seed()
|
||||||
|
|
||||||
if grid:
|
if grid:
|
||||||
@ -236,8 +238,14 @@ The vast majority of these arguments default to reasonable values.
|
|||||||
iterations=iterations,
|
iterations=iterations,
|
||||||
outdir=outdir)
|
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))
|
||||||
|
|
||||||
toc = time.time()
|
toc = time.time()
|
||||||
print(f'{batch_size * iterations} images generated in',"%4.2fs"% (toc-tic))
|
print(f'{image_count} images generated in',"%4.2fs"% (toc-tic))
|
||||||
|
|
||||||
return images
|
return images
|
||||||
|
|
||||||
@ -305,9 +313,11 @@ The vast majority of these arguments default to reasonable values.
|
|||||||
images = list()
|
images = list()
|
||||||
seeds = list()
|
seeds = list()
|
||||||
filename = None
|
filename = None
|
||||||
|
image_count = 0 # actual number of iterations performed
|
||||||
|
|
||||||
tic = time.time()
|
tic = time.time()
|
||||||
|
|
||||||
|
try:
|
||||||
with torch.no_grad():
|
with torch.no_grad():
|
||||||
with precision_scope("cuda"):
|
with precision_scope("cuda"):
|
||||||
with model.ema_scope():
|
with model.ema_scope():
|
||||||
@ -341,9 +351,8 @@ The vast majority of these arguments default to reasonable values.
|
|||||||
else:
|
else:
|
||||||
all_samples.append(x_samples)
|
all_samples.append(x_samples)
|
||||||
seeds.append(seed)
|
seeds.append(seed)
|
||||||
|
image_count += 1
|
||||||
seed = self._new_seed()
|
seed = self._new_seed()
|
||||||
|
|
||||||
if grid:
|
if grid:
|
||||||
images = self._make_grid(samples=all_samples,
|
images = self._make_grid(samples=all_samples,
|
||||||
seeds=seeds,
|
seeds=seeds,
|
||||||
@ -351,8 +360,13 @@ The vast majority of these arguments default to reasonable values.
|
|||||||
iterations=iterations,
|
iterations=iterations,
|
||||||
outdir=outdir)
|
outdir=outdir)
|
||||||
|
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print('Partial results will be returned; if --grid was requested, nothing will be returned.')
|
||||||
|
except RuntimeError as e:
|
||||||
|
print(str(e))
|
||||||
|
|
||||||
toc = time.time()
|
toc = time.time()
|
||||||
print(f'{batch_size * iterations} images generated in',"%4.2fs"% (toc-tic))
|
print(f'{image_count} images generated in',"%4.2fs"% (toc-tic))
|
||||||
|
|
||||||
return images
|
return images
|
||||||
|
|
||||||
|
@ -85,6 +85,7 @@ def main():
|
|||||||
cmd_parser = create_cmd_parser()
|
cmd_parser = create_cmd_parser()
|
||||||
main_loop(t2i,cmd_parser,log,infile)
|
main_loop(t2i,cmd_parser,log,infile)
|
||||||
log.close()
|
log.close()
|
||||||
|
if infile:
|
||||||
infile.close()
|
infile.close()
|
||||||
|
|
||||||
|
|
||||||
@ -157,19 +158,12 @@ def main_loop(t2i,parser,log,infile):
|
|||||||
print("Try again with a prompt!")
|
print("Try again with a prompt!")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
|
||||||
if opt.init_img is None:
|
if opt.init_img is None:
|
||||||
results = t2i.txt2img(**vars(opt))
|
results = t2i.txt2img(**vars(opt))
|
||||||
else:
|
else:
|
||||||
results = t2i.img2img(**vars(opt))
|
results = t2i.img2img(**vars(opt))
|
||||||
print("Outputs:")
|
print("Outputs:")
|
||||||
write_log_message(t2i,opt,results,log)
|
write_log_message(t2i,opt,results,log)
|
||||||
except KeyboardInterrupt:
|
|
||||||
print('*interrupted*')
|
|
||||||
continue
|
|
||||||
except RuntimeError as e:
|
|
||||||
print(str(e))
|
|
||||||
continue
|
|
||||||
|
|
||||||
|
|
||||||
print("goodbye!")
|
print("goodbye!")
|
||||||
|
Loading…
Reference in New Issue
Block a user