Update app.py
Browse files
app.py
CHANGED
@@ -83,9 +83,9 @@ def query(prompt, is_negative=False, steps=35, cfg_scale=7, sampler="DPM++ 2M Ka
|
|
83 |
return None
|
84 |
|
85 |
examples = [
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
]
|
90 |
|
91 |
def encode_image(image_path):
|
@@ -146,7 +146,6 @@ def feifeichat(image):
|
|
146 |
|
147 |
# CSS to style the app
|
148 |
css = """
|
149 |
-
.gradio-container {background-color: MediumAquaMarine}
|
150 |
footer{display:none !important}
|
151 |
#app-container {
|
152 |
max-width: 930px;
|
@@ -159,20 +158,19 @@ footer{display:none !important}
|
|
159 |
with gr.Blocks(theme=theme, css=css) as app:
|
160 |
# Add a title to the app
|
161 |
gr.HTML("<center><h1>π¨ Stable Diffusion 3.5 Large Turbo + π¬π§</h1></center>")
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
with gr.Column():
|
169 |
output_text = gr.Textbox(label="Flux Prompt βοΈ", show_copy_button = True)
|
170 |
clr_button =gr.Button("Clear ποΈ ",variant="primary", elem_id="clear_button")
|
171 |
clr_button.click(lambda: (None, None), None, [input_img, output_text], queue=False, show_api=False)
|
172 |
|
173 |
submit_btn.click(feifeichat, [input_img], [output_text])
|
174 |
-
|
175 |
-
#Create image from prompt
|
176 |
with gr.TabItem("βοΈ Text to Image πΌ", visible=True):
|
177 |
# Container for all the UI elements
|
178 |
with gr.Column(elem_id="app-container"):
|
@@ -203,39 +201,35 @@ with gr.Blocks(theme=theme, css=css) as app:
|
|
203 |
clear_prompt.click(lambda: (None), None, [text_prompt], queue=False, show_api=False)
|
204 |
|
205 |
with gr.Column(elem_id="app-container"):
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
with gr.Row():
|
212 |
-
clear_results = gr.Button(value="Clear Image ποΈ", variant="primary", elem_id="clear_button")
|
213 |
-
clear_results.click(lambda: (None), None, [image_output], queue=False, show_api=False)
|
214 |
-
|
215 |
-
with gr.Row():
|
216 |
gr.Examples(
|
217 |
examples = examples,
|
218 |
inputs = [text_prompt],
|
219 |
)
|
220 |
-
|
|
|
|
|
|
|
|
|
221 |
# Bind the button to the query function with the added width and height inputs
|
222 |
-
|
223 |
text_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength, width, height], outputs=image_output)
|
224 |
|
225 |
-
|
226 |
-
with gr.
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
clear_results.click(lambda: (None, None), None, [image_input, image_output])
|
236 |
-
|
237 |
|
238 |
-
with gr.
|
239 |
with gr.Column():
|
240 |
with gr.Row():
|
241 |
with gr.Column():
|
|
|
83 |
return None
|
84 |
|
85 |
examples = [
|
86 |
+
"a beautiful woman with blonde hair and blue eyes",
|
87 |
+
"a beautiful woman with brown hair and grey eyes",
|
88 |
+
"a beautiful woman with black hair and brown eyes",
|
89 |
]
|
90 |
|
91 |
def encode_image(image_path):
|
|
|
146 |
|
147 |
# CSS to style the app
|
148 |
css = """
|
|
|
149 |
footer{display:none !important}
|
150 |
#app-container {
|
151 |
max-width: 930px;
|
|
|
158 |
with gr.Blocks(theme=theme, css=css) as app:
|
159 |
# Add a title to the app
|
160 |
gr.HTML("<center><h1>π¨ Stable Diffusion 3.5 Large Turbo + π¬π§</h1></center>")
|
161 |
+
with gr.Tabs() as tabs:
|
162 |
+
with gr.TabItem(label="πΌ Image To Prompt π", visible=True):
|
163 |
+
with gr.Row():
|
164 |
+
with gr.Column():
|
165 |
+
input_img = gr.Image(label="Input Picture πΌοΈ",height=320,type="filepath")
|
166 |
+
submit_btn = gr.Button(value="Submit", variant='primary')
|
167 |
with gr.Column():
|
168 |
output_text = gr.Textbox(label="Flux Prompt βοΈ", show_copy_button = True)
|
169 |
clr_button =gr.Button("Clear ποΈ ",variant="primary", elem_id="clear_button")
|
170 |
clr_button.click(lambda: (None, None), None, [input_img, output_text], queue=False, show_api=False)
|
171 |
|
172 |
submit_btn.click(feifeichat, [input_img], [output_text])
|
173 |
+
|
|
|
174 |
with gr.TabItem("βοΈ Text to Image πΌ", visible=True):
|
175 |
# Container for all the UI elements
|
176 |
with gr.Column(elem_id="app-container"):
|
|
|
201 |
clear_prompt.click(lambda: (None), None, [text_prompt], queue=False, show_api=False)
|
202 |
|
203 |
with gr.Column(elem_id="app-container"):
|
204 |
+
with gr.Group():
|
205 |
+
# Image output area to display the generated image
|
206 |
+
with gr.Row():
|
207 |
+
image_output = gr.Image(type="pil", label="Image Output", format="png", show_share_button=False, elem_id="gallery")
|
208 |
+
|
|
|
|
|
|
|
|
|
|
|
209 |
gr.Examples(
|
210 |
examples = examples,
|
211 |
inputs = [text_prompt],
|
212 |
)
|
213 |
+
with gr.Group():
|
214 |
+
with gr.Row():
|
215 |
+
clear_results = gr.Button(value="Clear Image ποΈ", variant="primary", elem_id="clear_button")
|
216 |
+
clear_results.click(lambda: (None), None, [image_output], queue=False, show_api=False)
|
217 |
+
|
218 |
# Bind the button to the query function with the added width and height inputs
|
|
|
219 |
text_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength, width, height], outputs=image_output)
|
220 |
|
221 |
+
with gr.TabItem("π Flip Image", visible=True):
|
222 |
+
with gr.Row():
|
223 |
+
image_input = gr.Image(label="Upload Image", height=320, type="filepath")
|
224 |
+
image_output = gr.Image(format="png")
|
225 |
+
with gr.Row():
|
226 |
+
image_button = gr.Button("Run", variant='primary')
|
227 |
+
image_button.click(flip_image, inputs=image_input, outputs=image_output)
|
228 |
+
with gr.Row():
|
229 |
+
clear_results = gr.Button(value="Clear Image", variant="primary", elem_id="clear_button")
|
230 |
+
clear_results.click(lambda: (None, None), None, [image_input, image_output])
|
|
|
|
|
231 |
|
232 |
+
with gr.TabItem("βΉοΈ Tips", visible=True):
|
233 |
with gr.Column():
|
234 |
with gr.Row():
|
235 |
with gr.Column():
|