add timing info and change toast to put_success

This commit is contained in:
tonydero 2024-08-11 20:59:50 -06:00
parent c43d5affb3
commit 27cff1b27b

View File

@ -43,10 +43,6 @@ def flux_run(prompt, height, width, num_images_per_prompt, num_inference_steps,
)
# print('Max mem allocated (GB) while denoising:', torch.cuda.max_memory_allocated() / (1024 ** 3))
# import matplotlib.pyplot as plt
# plt.imshow(image)
# image.save("./whitehenge.png")
# plt.show()
for idx, image in enumerate(output.images):
timestamp = datetime.now().strftime("%Y%m%d%-H%M%S")
image_name = f'{slugify(prompt[:64])}-{idx}-{timestamp}.png'
@ -58,11 +54,12 @@ def btn_click(btn_val):
dirpath = Path(DIR_NAME)
if btn_val == 'Generate':
with put_loading():
put_text("Generating images...")
# time.sleep(3) # Some time-consuming operations
start_time = datetime.now()
put_text("Started generating images at " + start_time.strftime("%H:%M:%S"))
flux_run(pin.pin.prompt, 720, 1280, 4, 4, 128, dirpath)
# put_text("The answer of the universe is 42")
toast("Images Generated!")
stop_time = datetime.now()
run_time = stop_time - start_time
put_success("Images finished generating in" + run_time.strftime("%M:%S"), closeable=True)
def main(): # PyWebIO application function
put_text("Prompt:", inline=True)