From 217788bfedda6058bc2232bcb18a434d650ae9a1 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 13 Dec 2023 03:09:02 +0000 Subject: [PATCH] Update --- .../frontend/src/src/App.svelte | 5 +++-- .../stable_diffusion_xl_turbo_web.py | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/06_gpu_and_ml/stable_diffusion/stable_diffusion_xl_turbo_web_demo/frontend/src/src/App.svelte b/06_gpu_and_ml/stable_diffusion/stable_diffusion_xl_turbo_web_demo/frontend/src/src/App.svelte index 210526d25..7c703d0bf 100644 --- a/06_gpu_and_ml/stable_diffusion/stable_diffusion_xl_turbo_web_demo/frontend/src/src/App.svelte +++ b/06_gpu_and_ml/stable_diffusion/stable_diffusion_xl_turbo_web_demo/frontend/src/src/App.svelte @@ -20,7 +20,8 @@ import { rejects } from "assert"; let value: string; - let promptPlaceholder: string = "studio ghibli, 8k, wolf ..."; + let promptPlaceholder: string = "studio ghibli, 8k, wolf etc...."; + let promptPlaceholderValue: string = "studio ghibli, 8k, wolf"; let imgInput: HTMLImageElement; let imgOutput: HTMLImageElement; let canvasDrawLayer: HTMLCanvasElement; @@ -211,7 +212,7 @@ const formData = new FormData(); formData.append("image", data, "image.jpg"); - formData.append("prompt", value || promptPlaceholder); + formData.append("prompt", value || promptPlaceholderValue); const sentAt = new Date().getTime(); fetch(window.INFERENCE_BASE_URL, { diff --git a/06_gpu_and_ml/stable_diffusion/stable_diffusion_xl_turbo_web_demo/stable_diffusion_xl_turbo_web.py b/06_gpu_and_ml/stable_diffusion/stable_diffusion_xl_turbo_web_demo/stable_diffusion_xl_turbo_web.py index 5cde88241..2df8caead 100644 --- a/06_gpu_and_ml/stable_diffusion/stable_diffusion_xl_turbo_web_demo/stable_diffusion_xl_turbo_web.py +++ b/06_gpu_and_ml/stable_diffusion/stable_diffusion_xl_turbo_web_demo/stable_diffusion_xl_turbo_web.py @@ -1,5 +1,3 @@ -import base64 -import json import time from pathlib import Path @@ -82,13 +80,17 @@ def __enter__(self): ) @web_endpoint(method="POST") - async def inference(self, image: UploadFile = File(...), prompt: str = Form(...)): + async def inference( + self, image: UploadFile = File(...), prompt: str = Form(...) + ): t00 = time.time() img_data_in = await image.read() print("loading time:", time.time() - t00) - init_image = load_image(Image.open(BytesIO(img_data_in))).resize((512, 512)) - num_inference_steps = 2 + init_image = load_image(Image.open(BytesIO(img_data_in))).resize( + (512, 512) + ) + num_inference_steps = 3 # note: anything under 0.5 strength gives blurry results strength = 0.55 assert num_inference_steps * strength >= 1