alfredplpl commited on
Commit
4af9c2b
1 Parent(s): 19fd5c6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ref: https://huggingface.co/spaces/multimodalart/cosxl
2
+ import gradio as gr
3
+ from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
4
+ import spaces
5
+ import torch
6
+
7
+ model_id = "aipicasso/emi-2"
8
+ token=os.envron["TOKEN"]
9
+
10
+ scheduler = EulerAncestralDiscreteScheduler.from_pretraind(model_id)
11
+ pipe_normal = StableDiffusionXLPipeline.from_pretrained(model_id, scheduler=scheduler, torch_dtype=torch.bfloat16)
12
+ pipe_normal.to("cuda")
13
+
14
+ @spaces.GPU
15
+ def run_normal(prompt, negative_prompt="", guidance_scale=7, progress=gr.Progress(track_tqdm=True)):
16
+ return pipe_normal(prompt, negative_prompt=negative_prompt, guidance_scale=guidance_scale, num_inference_steps=20).images[0]
17
+
18
+ normal_examples = ["portrait photo of a girl, photograph, highly detailed face, depth of field, moody light, golden hour, style by Dan Winters, Russell James, Steve McCurry, centered, extremely detailed, Nikon D850, award winning photography", "backlit photography of a dog", "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k", "A photo of beautiful mountain with realistic sunset and blue lake, highly detailed, masterpiece"]
19
+ with gr.Blocks(css=css) as demo:
20
+ gr.Markdown('''# Emi 2
21
+ Official demo for Emi 2
22
+ ''')
23
+ with gr.Group():
24
+ with gr.Row():
25
+ prompt_normal = gr.Textbox(show_label=False, scale=4, placeholder="Your prompt, e.g.: backlit photography of a dog")
26
+ button_normal = gr.Button("Generate", min_width=120)
27
+ output_normal = gr.Image(label="Your result image", interactive=False)
28
+ with gr.Accordion("Advanced Settings", open=False):
29
+ negative_prompt_normal = gr.Textbox(label="Negative Prompt")
30
+ guidance_scale_normal = gr.Number(label="Guidance Scale", value=7)
31
+ gr.Examples(examples=normal_examples, fn=run_normal, inputs=[prompt_normal], outputs=[output_normal], cache_examples=True)
32
+
33
+ gr.on(
34
+ triggers=[
35
+ button_normal.click,
36
+ prompt_normal.submit
37
+ ],
38
+ fn=run_normal,
39
+ inputs=[prompt_normal, negative_prompt_normal, guidance_scale_normal],
40
+ outputs=[output_normal],
41
+ )
42
+ if __name__ == "__main__":
43
+ demo.launch(share=True)