Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,27 +1,27 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
import
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
pipe.
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
demo.launch()
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from diffusers import DiffusionPipeline
|
| 3 |
+
import gradio as gr
|
| 4 |
+
|
| 5 |
+
# Load model with float16 for GPU or float32 for CPU
|
| 6 |
+
dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
| 7 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 8 |
+
|
| 9 |
+
pipe = DiffusionPipeline.from_pretrained(
|
| 10 |
+
"CompVis/stable-diffusion-v1-4", torch_dtype=dtype
|
| 11 |
+
)
|
| 12 |
+
pipe.load_lora_weights("EliKet/train_text_to_img")
|
| 13 |
+
pipe.to(device)
|
| 14 |
+
|
| 15 |
+
def generate_image(prompt):
|
| 16 |
+
image = pipe(prompt).images[0]
|
| 17 |
+
return image
|
| 18 |
+
|
| 19 |
+
demo = gr.Interface(
|
| 20 |
+
fn=generate_image,
|
| 21 |
+
inputs=gr.Textbox(placeholder="Enter your image prompt here..."),
|
| 22 |
+
outputs="image",
|
| 23 |
+
title="Text-to-Image Generator (Lynx)",
|
| 24 |
+
description="Type a prompt like 'a lynx in the snowy forest, ultra-detailed'."
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
demo.launch()
|