Spaces:
Runtime error
Runtime error
lixiang46
commited on
Commit
•
ce743f5
1
Parent(s):
ba2a5e2
update
Browse files
app.py
CHANGED
@@ -38,104 +38,97 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance
|
|
38 |
return image
|
39 |
|
40 |
examples = [
|
41 |
-
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|
42 |
-
"An astronaut riding a green horse",
|
43 |
-
"A delicious ceviche cheesecake slice",
|
44 |
-
]
|
45 |
|
46 |
-
|
47 |
-
#col-container {
|
48 |
-
margin: 0 auto;
|
49 |
-
max-width: 520px;
|
50 |
-
}
|
51 |
-
"""
|
52 |
|
53 |
if torch.cuda.is_available():
|
54 |
power_device = "GPU"
|
55 |
else:
|
56 |
power_device = "CPU"
|
57 |
|
58 |
-
with gr.Blocks(
|
59 |
|
60 |
-
with gr.
|
61 |
gr.Markdown(f"""
|
62 |
# Text-to-Image Gradio Template
|
63 |
Currently running on {power_device}.
|
64 |
""")
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
prompt = gr.Text(
|
69 |
-
label="Prompt",
|
70 |
-
show_label=False,
|
71 |
-
max_lines=1,
|
72 |
-
placeholder="Enter your prompt",
|
73 |
-
container=False,
|
74 |
-
)
|
75 |
-
|
76 |
-
run_button = gr.Button("Run", scale=0)
|
77 |
-
|
78 |
-
result = gr.Image(label="Result", show_label=False)
|
79 |
-
|
80 |
-
with gr.Accordion("Advanced Settings", open=False):
|
81 |
-
|
82 |
-
negative_prompt = gr.Text(
|
83 |
-
label="Negative prompt",
|
84 |
-
max_lines=1,
|
85 |
-
placeholder="Enter a negative prompt",
|
86 |
-
visible=False,
|
87 |
-
)
|
88 |
-
|
89 |
-
seed = gr.Slider(
|
90 |
-
label="Seed",
|
91 |
-
minimum=0,
|
92 |
-
maximum=MAX_SEED,
|
93 |
-
step=1,
|
94 |
-
value=0,
|
95 |
-
)
|
96 |
-
|
97 |
-
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
98 |
-
|
99 |
with gr.Row():
|
100 |
-
|
101 |
-
|
102 |
-
label="
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
height = gr.Slider(
|
110 |
-
label="Height",
|
111 |
-
minimum=256,
|
112 |
-
maximum=MAX_IMAGE_SIZE,
|
113 |
-
step=32,
|
114 |
-
value=512,
|
115 |
)
|
116 |
-
|
117 |
with gr.Row():
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
value=0.0,
|
125 |
)
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
step=1,
|
132 |
-
value=
|
133 |
)
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
gr.Examples(
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
|
140 |
run_button.click(
|
141 |
fn = infer,
|
|
|
38 |
return image
|
39 |
|
40 |
examples = [
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
]
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
if torch.cuda.is_available():
|
45 |
power_device = "GPU"
|
46 |
else:
|
47 |
power_device = "CPU"
|
48 |
|
49 |
+
with gr.Blocks() as demo:
|
50 |
|
51 |
+
with gr.Row():
|
52 |
gr.Markdown(f"""
|
53 |
# Text-to-Image Gradio Template
|
54 |
Currently running on {power_device}.
|
55 |
""")
|
56 |
|
57 |
+
with gr.Row():
|
58 |
+
with gr.Column(elem_id="col-container"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
with gr.Row():
|
60 |
+
ip_adapter_image = gr.Image(label="IP-Adapter Image", type="pil")
|
61 |
+
ip_adapter_scale = gr.Slider(
|
62 |
+
label="Image influence scale",
|
63 |
+
info="Use 1 for creating variations",
|
64 |
+
minimum=0.0,
|
65 |
+
maximum=1.0,
|
66 |
+
step=0.05,
|
67 |
+
value=0.5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
)
|
|
|
69 |
with gr.Row():
|
70 |
+
prompt = gr.Text(
|
71 |
+
label="Prompt",
|
72 |
+
show_label=False,
|
73 |
+
max_lines=1,
|
74 |
+
placeholder="Enter your prompt",
|
75 |
+
container=False,
|
|
|
76 |
)
|
77 |
+
run_button = gr.Button("Run", scale=0)
|
78 |
+
with gr.Accordion("Advanced Settings", open=False):
|
79 |
+
negative_prompt = gr.Text(
|
80 |
+
label="Negative prompt",
|
81 |
+
max_lines=1,
|
82 |
+
placeholder="Enter a negative prompt",
|
83 |
+
visible=True,
|
84 |
+
)
|
85 |
+
seed = gr.Slider(
|
86 |
+
label="Seed",
|
87 |
+
minimum=0,
|
88 |
+
maximum=MAX_SEED,
|
89 |
step=1,
|
90 |
+
value=0,
|
91 |
)
|
92 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
93 |
+
with gr.Row():
|
94 |
+
width = gr.Slider(
|
95 |
+
label="Width",
|
96 |
+
minimum=256,
|
97 |
+
maximum=MAX_IMAGE_SIZE,
|
98 |
+
step=32,
|
99 |
+
value=512,
|
100 |
+
)
|
101 |
+
height = gr.Slider(
|
102 |
+
label="Height",
|
103 |
+
minimum=256,
|
104 |
+
maximum=MAX_IMAGE_SIZE,
|
105 |
+
step=32,
|
106 |
+
value=512,
|
107 |
+
)
|
108 |
+
with gr.Row():
|
109 |
+
guidance_scale = gr.Slider(
|
110 |
+
label="Guidance scale",
|
111 |
+
minimum=0.0,
|
112 |
+
maximum=10.0,
|
113 |
+
step=0.1,
|
114 |
+
value=0.0,
|
115 |
+
)
|
116 |
+
num_inference_steps = gr.Slider(
|
117 |
+
label="Number of inference steps",
|
118 |
+
minimum=10,
|
119 |
+
maximum=50,
|
120 |
+
step=1,
|
121 |
+
value=25,
|
122 |
+
)
|
123 |
+
|
124 |
+
with gr.Column(elem_id="col-container"):
|
125 |
+
result = gr.Image(label="Result", show_label=False)
|
126 |
+
|
127 |
+
with gr.Row():
|
128 |
gr.Examples(
|
129 |
+
examples = examples,
|
130 |
+
inputs = [prompt]
|
131 |
+
)
|
132 |
|
133 |
run_button.click(
|
134 |
fn = infer,
|