My-AI-Projects commited on
Commit
2df394e
·
verified ·
1 Parent(s): 4ec62f9

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from diffusers import KolorsPipeline
4
+
5
+ pipeline= KolorsPipeline.from_pretrained(
6
+ "Kwai-Kolors/Kolors-diffusers",
7
+ torch_dtype=torch.float16,
8
+ variant="fp16"
9
+ ).to("cuda" if torch.cuda.is_available() else "cpu")
10
+
11
+ # Function to generate image from prompt
12
+ def generate_image(prompt):
13
+ # Use the pipeline to generate an image from the text prompt
14
+ image = pipeline(prompt).images[0]
15
+ return image
16
+
17
+ # Create Gradio interface
18
+ iface = gr.Interface(
19
+ fn=generate_image, # Function that generates the image
20
+ inputs=gr.Textbox(lines=2, placeholder="Enter your prompt"), # Textbox input for the prompt
21
+ outputs="image", # Output is an image
22
+ title="Kwai-Kolors Image Generator",
23
+ description="Generate images from text prompts using the Kwai-Kolors diffusion model."
24
+ )
25
+
26
+ # Launch the app
27
+ iface.launch()