Spaces:
Running
Running
Commit
·
36abcb2
1
Parent(s):
7c203d2
add input image column
Browse files
app.py
CHANGED
@@ -46,7 +46,7 @@ def infer(
|
|
46 |
negative_prompt=negative_prompt,
|
47 |
guidance_scale=0.,
|
48 |
num_inference_steps=4,
|
49 |
-
width=
|
50 |
height=1080,
|
51 |
max_sequence_length=256,
|
52 |
).images[0]
|
@@ -68,90 +68,94 @@ css = """
|
|
68 |
"""
|
69 |
|
70 |
with gr.Blocks(css=css) as demo:
|
71 |
-
with gr.
|
72 |
-
gr.
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
show_label=False,
|
78 |
-
max_lines=1,
|
79 |
-
placeholder="Enter your prompt",
|
80 |
-
container=False,
|
81 |
-
)
|
82 |
-
|
83 |
-
run_button = gr.Button("Run", scale=0, variant="primary")
|
84 |
-
|
85 |
-
result = gr.Image(label="Result", show_label=False)
|
86 |
-
|
87 |
-
with gr.Accordion("Advanced Settings", open=False):
|
88 |
-
negative_prompt = gr.Text(
|
89 |
-
label="Negative prompt",
|
90 |
-
max_lines=1,
|
91 |
-
placeholder="Enter a negative prompt",
|
92 |
-
visible=False,
|
93 |
-
)
|
94 |
-
|
95 |
-
seed = gr.Slider(
|
96 |
-
label="Seed",
|
97 |
-
minimum=0,
|
98 |
-
maximum=MAX_SEED,
|
99 |
-
step=1,
|
100 |
-
value=0,
|
101 |
-
)
|
102 |
-
|
103 |
-
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
104 |
|
105 |
with gr.Row():
|
106 |
-
|
107 |
-
label="
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
)
|
113 |
|
114 |
-
|
115 |
-
label="Height",
|
116 |
-
minimum=256,
|
117 |
-
maximum=MAX_IMAGE_SIZE,
|
118 |
-
step=32,
|
119 |
-
value=1024, # Replace with defaults that work for your model
|
120 |
-
)
|
121 |
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
|
|
129 |
)
|
130 |
|
131 |
-
|
132 |
-
label="
|
133 |
-
minimum=
|
134 |
-
maximum=
|
135 |
step=1,
|
136 |
-
value=
|
137 |
)
|
138 |
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
if __name__ == "__main__":
|
157 |
demo.launch()
|
|
|
46 |
negative_prompt=negative_prompt,
|
47 |
guidance_scale=0.,
|
48 |
num_inference_steps=4,
|
49 |
+
width=1420,
|
50 |
height=1080,
|
51 |
max_sequence_length=256,
|
52 |
).images[0]
|
|
|
68 |
"""
|
69 |
|
70 |
with gr.Blocks(css=css) as demo:
|
71 |
+
with gr.Row():
|
72 |
+
with gr.Column(elem_id="col-input-image"):
|
73 |
+
gr.Markdown(" # Drop your image here")
|
74 |
+
gr.Image()
|
75 |
+
with gr.Column(elem_id="col-container"):
|
76 |
+
gr.Markdown(" # Text-to-Image Gradio Template")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
with gr.Row():
|
79 |
+
prompt = gr.Text(
|
80 |
+
label="Prompt",
|
81 |
+
show_label=False,
|
82 |
+
max_lines=1,
|
83 |
+
placeholder="Enter your prompt",
|
84 |
+
container=False,
|
85 |
)
|
86 |
|
87 |
+
run_button = gr.Button("Run", scale=0, variant="primary")
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
+
result = gr.Image(label="Result", show_label=False)
|
90 |
+
|
91 |
+
with gr.Accordion("Advanced Settings", open=False):
|
92 |
+
negative_prompt = gr.Text(
|
93 |
+
label="Negative prompt",
|
94 |
+
max_lines=1,
|
95 |
+
placeholder="Enter a negative prompt",
|
96 |
+
visible=False,
|
97 |
)
|
98 |
|
99 |
+
seed = gr.Slider(
|
100 |
+
label="Seed",
|
101 |
+
minimum=0,
|
102 |
+
maximum=MAX_SEED,
|
103 |
step=1,
|
104 |
+
value=0,
|
105 |
)
|
106 |
|
107 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
108 |
+
|
109 |
+
with gr.Row():
|
110 |
+
width = gr.Slider(
|
111 |
+
label="Width",
|
112 |
+
minimum=256,
|
113 |
+
maximum=MAX_IMAGE_SIZE,
|
114 |
+
step=32,
|
115 |
+
value=1024, # Replace with defaults that work for your model
|
116 |
+
)
|
117 |
+
|
118 |
+
height = gr.Slider(
|
119 |
+
label="Height",
|
120 |
+
minimum=256,
|
121 |
+
maximum=MAX_IMAGE_SIZE,
|
122 |
+
step=32,
|
123 |
+
value=1024, # Replace with defaults that work for your model
|
124 |
+
)
|
125 |
+
|
126 |
+
with gr.Row():
|
127 |
+
guidance_scale = gr.Slider(
|
128 |
+
label="Guidance scale",
|
129 |
+
minimum=0.0,
|
130 |
+
maximum=10.0,
|
131 |
+
step=0.1,
|
132 |
+
value=0.0, # Replace with defaults that work for your model
|
133 |
+
)
|
134 |
+
|
135 |
+
num_inference_steps = gr.Slider(
|
136 |
+
label="Number of inference steps",
|
137 |
+
minimum=1,
|
138 |
+
maximum=50,
|
139 |
+
step=1,
|
140 |
+
value=2, # Replace with defaults that work for your model
|
141 |
+
)
|
142 |
+
|
143 |
+
gr.Examples(examples=examples, inputs=[prompt])
|
144 |
+
gr.on(
|
145 |
+
triggers=[run_button.click, prompt.submit],
|
146 |
+
fn=infer,
|
147 |
+
inputs=[
|
148 |
+
prompt,
|
149 |
+
negative_prompt,
|
150 |
+
seed,
|
151 |
+
randomize_seed,
|
152 |
+
width,
|
153 |
+
height,
|
154 |
+
guidance_scale,
|
155 |
+
num_inference_steps,
|
156 |
+
],
|
157 |
+
outputs=[result, seed],
|
158 |
+
)
|
159 |
|
160 |
if __name__ == "__main__":
|
161 |
demo.launch()
|