Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,24 @@
|
|
1 |
-
import torch
|
2 |
-
from diffusers import FluxPipeline
|
3 |
import gradio as gr
|
|
|
|
|
4 |
|
5 |
-
#
|
6 |
-
|
7 |
-
pipe.to("cuda")
|
8 |
|
|
|
9 |
def generate_image(prompt):
|
10 |
-
#
|
11 |
-
image =
|
12 |
-
|
13 |
-
guidance_scale=3.5,
|
14 |
-
width=768, height=1024,
|
15 |
-
).images[0]
|
16 |
-
# Save the image
|
17 |
-
image_path = "generated_image.png"
|
18 |
-
image.save(image_path)
|
19 |
-
return image_path
|
20 |
|
21 |
-
#
|
22 |
-
|
23 |
-
fn=generate_image,
|
24 |
-
inputs=gr.Textbox(
|
25 |
-
outputs=
|
26 |
-
title="Image Generator",
|
27 |
-
description="Generate images
|
28 |
)
|
29 |
|
30 |
-
# Launch the
|
31 |
-
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from diffusers import DiffusionPipeline
|
3 |
+
import torch
|
4 |
|
5 |
+
# Load the Kwai-Kolors diffusion model
|
6 |
+
pipeline = DiffusionPipeline.from_pretrained("Kwai-Kolors/Kolors").to("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
7 |
|
8 |
+
# Function to generate image from prompt
|
9 |
def generate_image(prompt):
|
10 |
+
# Use the pipeline to generate an image from the text prompt
|
11 |
+
image = pipeline(prompt).images[0]
|
12 |
+
return image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
+
# Create Gradio interface
|
15 |
+
iface = gr.Interface(
|
16 |
+
fn=generate_image, # Function that generates the image
|
17 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter your prompt"), # Textbox input for the prompt
|
18 |
+
outputs="image", # Output is an image
|
19 |
+
title="Kwai-Kolors Image Generator",
|
20 |
+
description="Generate images from text prompts using the Kwai-Kolors diffusion model."
|
21 |
)
|
22 |
|
23 |
+
# Launch the app
|
24 |
+
iface.launch()
|