kailouis commited on
Commit
cd068c6
·
verified ·
1 Parent(s): 1ecd9e5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from diffusers import FluxPipeline, DPMSolverMultistepScheduler
3
+
4
+ # Load the model
5
+ model_id = "black-forest-labs/FLUX.1-dev"
6
+ pipe = FluxPipeline.from_pretrained(model_id, torch_dtype=torch.float16, safety_checker=None)
7
+ pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
8
+ pipe.enable_xformers_memory_efficient_attention()
9
+
10
+ if torch.cuda.is_available():
11
+ pipe = pipe.to("cuda")
12
+
13
+ # Define the function to generate images
14
+ def generate_image(prompt):
15
+ image = pipe(prompt, num_inference_steps=25).images[0]
16
+ return image
17
+
18
+ # Title for your Space
19
+ title = "Kailouis AI Image Generator"
20
+
21
+ # Description for your Space
22
+ description = "Generate amazing images with Kailouis AI, powered by the FLUX.1-dev model."
23
+
24
+ # Create the UI
25
+ import gradio as gr
26
+
27
+ demo = gr.Interface(
28
+ fn=generate_image,
29
+ inputs=[gr.Textbox(lines=1, placeholder="Enter your prompt")],
30
+ outputs=[gr.Image(type="pil")],
31
+ title=title,
32
+ description=description,
33
+ )
34
+
35
+ demo.launch(share=True)