Update app.py
Browse files
app.py
CHANGED
|
@@ -29,16 +29,31 @@ def chat_fn(message, history):
|
|
| 29 |
return tokenizer.decode(output[0], skip_special_tokens=True)
|
| 30 |
|
| 31 |
# ---------------- IMAGE ----------------
|
| 32 |
-
# ---------- IMAGE MODEL ----------
|
| 33 |
from diffusers import StableDiffusionPipeline
|
|
|
|
| 34 |
|
| 35 |
img_pipe = StableDiffusionPipeline.from_pretrained(
|
| 36 |
"stabilityai/sdxl-turbo",
|
| 37 |
-
torch_dtype=torch.float32
|
|
|
|
| 38 |
)
|
| 39 |
|
|
|
|
| 40 |
img_pipe = img_pipe.to("cpu")
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
# ---------------- UI ----------------
|
| 44 |
with gr.Blocks(
|
|
|
|
| 29 |
return tokenizer.decode(output[0], skip_special_tokens=True)
|
| 30 |
|
| 31 |
# ---------------- IMAGE ----------------
|
|
|
|
| 32 |
from diffusers import StableDiffusionPipeline
|
| 33 |
+
import torch
|
| 34 |
|
| 35 |
img_pipe = StableDiffusionPipeline.from_pretrained(
|
| 36 |
"stabilityai/sdxl-turbo",
|
| 37 |
+
torch_dtype=torch.float32,
|
| 38 |
+
safety_checker=None
|
| 39 |
)
|
| 40 |
|
| 41 |
+
img_pipe.set_progress_bar_config(disable=True)
|
| 42 |
img_pipe = img_pipe.to("cpu")
|
| 43 |
|
| 44 |
+
def generate_image(prompt):
|
| 45 |
+
if not prompt.strip():
|
| 46 |
+
raise gr.Error("Prompt boş olamaz")
|
| 47 |
+
|
| 48 |
+
image = img_pipe(
|
| 49 |
+
prompt,
|
| 50 |
+
num_inference_steps=4,
|
| 51 |
+
guidance_scale=0.0
|
| 52 |
+
).images[0]
|
| 53 |
+
|
| 54 |
+
return image
|
| 55 |
+
|
| 56 |
+
|
| 57 |
|
| 58 |
# ---------------- UI ----------------
|
| 59 |
with gr.Blocks(
|