ameerazam08
commited on
Commit
•
80e89cb
1
Parent(s):
48c6826
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import space
|
3 |
+
|
4 |
+
from pipeline_diffusehigh_sdxl import DiffuseHighSDXLPipeline
|
5 |
+
pipeline = DiffuseHighSDXLPipeline.from_pretrained(
|
6 |
+
"stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16,
|
7 |
+
).to("cuda")
|
8 |
+
|
9 |
+
|
10 |
+
@space.GPU()
|
11 |
+
def process_(
|
12 |
+
prompt="",
|
13 |
+
target_height=[1536, 2048],
|
14 |
+
target_width=[1536, 2048],
|
15 |
+
):
|
16 |
+
negative_prompt = "blurry, ugly, duplicate, poorly drawn, deformed, mosaic"
|
17 |
+
|
18 |
+
image = pipeline(
|
19 |
+
prompt,
|
20 |
+
negative_prompt=negative_prompt,
|
21 |
+
target_height=target_height,
|
22 |
+
target_width=target_width,
|
23 |
+
enable_dwt=True,
|
24 |
+
dwt_steps=5,
|
25 |
+
enable_sharpening=True,
|
26 |
+
sharpness_factor=1.0,
|
27 |
+
).images[0]
|
28 |
+
|
29 |
+
return image
|
30 |
+
def create_demo():
|
31 |
+
with gr.Blocks(theme="bethecloud/storj_theme") as demo:
|
32 |
+
with gr.Row():
|
33 |
+
with gr.Column():
|
34 |
+
prompt = gr.Textbox(label="Prompt", value="A cat holding a sign that says hello world")
|
35 |
+
generate_button = gr.Button("Generate")
|
36 |
+
|
37 |
+
with gr.Column():
|
38 |
+
output_image = gr.Image(label="Generated Image")
|
39 |
+
|
40 |
+
generate_button.click(
|
41 |
+
fn=process_,
|
42 |
+
inputs=[prompt],
|
43 |
+
outputs=[output_image]
|
44 |
+
)
|
45 |
+
|
46 |
+
examples = [
|
47 |
+
"a tiny astronaut hatching from an egg on the moon",
|
48 |
+
"a cat holding a sign that says hello world",
|
49 |
+
"an anime illustration of a wiener schnitzel",
|
50 |
+
]
|
51 |
+
|
52 |
+
return demo
|
53 |
+
|
54 |
+
demo = create_demo()
|
55 |
+
demo.launch(share=True)
|