Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,29 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
|
|
3 |
|
4 |
-
# Load
|
5 |
-
|
|
|
6 |
|
7 |
-
# Define
|
8 |
-
def generate_image(prompt
|
9 |
-
# Generate
|
10 |
-
image =
|
11 |
return image
|
12 |
|
13 |
-
# Create
|
14 |
-
|
15 |
-
fn=generate_image,
|
16 |
-
inputs=gr.Textbox(label="Enter
|
17 |
-
outputs=gr.Image(
|
18 |
-
live=True
|
|
|
|
|
19 |
)
|
20 |
|
21 |
-
# Launch the
|
22 |
-
|
|
|
23 |
|
24 |
|
|
|
1 |
import gradio as gr
|
2 |
+
from diffusers import StableDiffusionPipeline
|
3 |
+
import torch
|
4 |
|
5 |
+
# Load the model (you can replace this with the specific Kwai-Kolors/Kolors model if available)
|
6 |
+
pipe = StableDiffusionPipeline.from_pretrained("Kwai-Kolors/Kolors")
|
7 |
+
pipe.to("cuda" if torch.cuda.is_available() else "cpu")
|
8 |
|
9 |
+
# Define function to generate image from text
|
10 |
+
def generate_image(prompt):
|
11 |
+
# Generate an image based on the provided text prompt
|
12 |
+
image = pipe(prompt).images[0]
|
13 |
return image
|
14 |
|
15 |
+
# Create Gradio interface for chatbot
|
16 |
+
interface = gr.Interface(
|
17 |
+
fn=generate_image,
|
18 |
+
inputs=gr.Textbox(label="Enter your prompt:"),
|
19 |
+
outputs=gr.Image(type="pil"),
|
20 |
+
live=True,
|
21 |
+
title="Text-to-Image Generation",
|
22 |
+
description="Enter a text prompt to generate a photorealistic image."
|
23 |
)
|
24 |
|
25 |
+
# Launch the interface
|
26 |
+
interface.launch()
|
27 |
+
|
28 |
|
29 |
|