recoilme commited on
Commit
a00a71d
1 Parent(s): d461311

Add application file

Browse files
Files changed (2) hide show
  1. app.py +44 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ import torch
4
+ from diffusers import DiffusionPipeline
5
+ from diffusers import EulerDiscreteScheduler
6
+
7
+
8
+ pipeline = DiffusionPipeline.from_pretrained("recoilme/ColorfulXL-Lightning",variant="fp16"#, torch_dtype=torch.float16
9
+ , use_safetensors=True)#.to("cuda")
10
+ pipeline.scheduler = EulerDiscreteScheduler.from_config(pipeline.scheduler.config, timestep_spacing="trailing")
11
+
12
+
13
+ def generate(prompt, negative_prompt, width, height, sample_steps):
14
+ return pipeline(prompt=prompt, guidance_scale=0, negative_prompt="", width=width, height=height, num_inference_steps=sample_steps).images[0]
15
+
16
+ with gr.Blocks() as interface:
17
+ with gr.Column():
18
+ with gr.Row():
19
+ with gr.Column():
20
+ prompt = gr.Textbox(label="Prompt", info="What do you want?", value="girl sitting on a small hill looking at night sky, back view, distant exploding moon, nights darkness, intricate circuits and sensors, photographic realism style, detailed textures, peacefulness, mysterious.", lines=4, interactive=True)
21
+ with gr.Column():
22
+ generate_button = gr.Button("Generate")
23
+ output = gr.Image()
24
+ with gr.Row():
25
+ with gr.Accordion(label="Advanced Settings", open=False):
26
+ with gr.Row():
27
+ with gr.Column():
28
+ width = gr.Slider(label="Width", info="The width in pixels of the generated image.", value=576, minimum=512, maximum=1280, step=64, interactive=True)
29
+ height = gr.Slider(label="Height", info="The height in pixels of the generated image.", value=832, minimum=512, maximum=1280, step=64, interactive=True)
30
+ with gr.Column():
31
+ sampling_steps = gr.Slider(label="Sampling Steps", info="The number of denoising steps.", value=5, minimum=3, maximum=10, step=1, interactive=True)
32
+
33
+ with gr.Row():
34
+ about_text = """
35
+ Based on: Stable Diffusion XL Image Generation interface built by Noa Roggendorff.
36
+
37
+ You can enter a prompt and negative prompt, adjust the image size and sampling steps, and click the "Generate" button to generate an image.
38
+ """
39
+ gr.Markdown(about_text)
40
+
41
+ generate_button.click(fn=generate, inputs=[prompt, negative_prompt, width, height, sampling_steps], outputs=[output])
42
+
43
+ if __name__ == "__main__":
44
+ interface.launch()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ diffusers
2
+ torch
3
+ gradio
4
+ accelerate
5
+ transformers