Spaces:
Running
Running
root
commited on
Commit
·
edc3311
1
Parent(s):
1fbcebe
Front-Back connect test
Browse files
app.py
CHANGED
|
@@ -125,6 +125,16 @@ def call_JS(sd_method, **kwargs):
|
|
| 125 |
param_str = json.dumps(kwargs)
|
| 126 |
return f"async (...x) => {{ return await SD.{sd_method}({{ x, ...{param_str} }}) ?? []; }}"
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
examples = [
|
| 130 |
'水墨蝴蝶和牡丹花,国画',
|
|
@@ -146,312 +156,300 @@ if __name__ == "__main__":
|
|
| 146 |
with block:
|
| 147 |
gr.HTML(read_content("header.html"))
|
| 148 |
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
with gr.Row():
|
| 445 |
-
button1 = gr.Button("Button", visible="primary")
|
| 446 |
-
button2 = gr.Button("Button", variant="primary")
|
| 447 |
-
image_mask = gr.Image(
|
| 448 |
-
value=None,
|
| 449 |
-
source="upload",
|
| 450 |
-
interactive=True,
|
| 451 |
-
tpye="pil",
|
| 452 |
-
tool="sketch",
|
| 453 |
-
image_mode="RGBA",
|
| 454 |
-
)
|
| 455 |
gr.HTML(read_content("footer.html"))
|
| 456 |
# gr.Image('./contributors.png')
|
| 457 |
|
|
|
|
| 125 |
param_str = json.dumps(kwargs)
|
| 126 |
return f"async (...x) => {{ return await SD.{sd_method}({{ x, ...{param_str} }}) ?? []; }}"
|
| 127 |
|
| 128 |
+
def img2img(input_list):
|
| 129 |
+
url = "http://flagart.baai.ac.cn/api/img2img/"
|
| 130 |
+
d = {"data":input_list}
|
| 131 |
+
r = requests.post(url, json=d, headers={"Content-Type": "application/json", "Accept": "*/*", "Accept-Encoding": "gzip, deflate, br", "Connection": "keep-alive"})
|
| 132 |
+
print(r)
|
| 133 |
+
result_text = r.text
|
| 134 |
+
content = json.loads(result_text)["data"][0]
|
| 135 |
+
print(content)
|
| 136 |
+
return
|
| 137 |
+
|
| 138 |
|
| 139 |
examples = [
|
| 140 |
'水墨蝴蝶和牡丹花,国画',
|
|
|
|
| 156 |
with block:
|
| 157 |
gr.HTML(read_content("header.html"))
|
| 158 |
|
| 159 |
+
with gr.Tabs() as tabs:
|
| 160 |
+
|
| 161 |
+
with gr.TabItem("文生图(Text-to-img)"):
|
| 162 |
+
|
| 163 |
+
with gr.Group():
|
| 164 |
+
with gr.Box():
|
| 165 |
+
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
| 166 |
+
text = gr.Textbox(
|
| 167 |
+
label="Prompt",
|
| 168 |
+
show_label=False,
|
| 169 |
+
max_lines=1,
|
| 170 |
+
placeholder="Input text(输入文字)",
|
| 171 |
+
interactive=True,
|
| 172 |
+
).style(
|
| 173 |
+
border=(True, False, True, True),
|
| 174 |
+
rounded=(True, False, False, True),
|
| 175 |
+
container=False,
|
| 176 |
+
)
|
| 177 |
|
| 178 |
+
btn = gr.Button("Generate image").style(
|
| 179 |
+
margin=False,
|
| 180 |
+
rounded=(True, True, True, True),
|
| 181 |
+
)
|
| 182 |
+
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
| 183 |
+
class_draw = gr.Dropdown(["通用(general)", "国画(traditional Chinese painting)",
|
| 184 |
+
"照片,摄影(picture photography)", "油画(oil painting)",
|
| 185 |
+
"铅笔素描(pencil sketch)", "CG",
|
| 186 |
+
"水彩画(watercolor painting)", "水墨画(ink and wash)",
|
| 187 |
+
"插画(illustrations)", "3D", "图生图(img2img)"],
|
| 188 |
+
label="生成类型(type)",
|
| 189 |
+
show_label=True,
|
| 190 |
+
value="通用(general)")
|
| 191 |
+
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
| 192 |
+
style_draw = gr.CheckboxGroup(["蒸汽朋克(steampunk)", "电影摄影风格(film photography)",
|
| 193 |
+
"概念艺术(concept art)", "Warming lighting",
|
| 194 |
+
"Dramatic lighting", "Natural lighting",
|
| 195 |
+
"虚幻引擎(unreal engine)", "4k", "8k",
|
| 196 |
+
"充满细节(full details)"],
|
| 197 |
+
label="画面风格(style)",
|
| 198 |
+
show_label=True,
|
| 199 |
+
)
|
| 200 |
+
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
| 201 |
+
sample_size = gr.Slider(minimum=1,
|
| 202 |
+
maximum=4,
|
| 203 |
+
step=1,
|
| 204 |
+
label="生成数量(number)",
|
| 205 |
+
show_label=True,
|
| 206 |
+
interactive=True,
|
| 207 |
+
)
|
| 208 |
+
|
| 209 |
+
gallery = gr.Gallery(
|
| 210 |
+
label="Generated images", show_label=False, elem_id="gallery"
|
| 211 |
+
).style(grid=[2], height="auto")
|
| 212 |
+
|
| 213 |
+
gr.Examples(examples=examples, fn=request_images, inputs=text, outputs=gallery, examples_per_page=100)
|
| 214 |
+
text.submit(request_images, inputs=[text, class_draw, style_draw, sample_size], outputs=gallery)
|
| 215 |
+
btn.click(request_images, inputs=[text, class_draw, style_draw, sample_size], outputs=gallery)
|
| 216 |
+
|
| 217 |
+
with gr.TabItem("图生图(Img-to-Img)", id="img2img_tab"):
|
| 218 |
+
with gr.Row(elem_id="prompt_row"):
|
| 219 |
+
img2img_prompt = gr.Textbox(label="Prompt",
|
| 220 |
+
elem_id='img2img_prompt_input',
|
| 221 |
+
placeholder="神奇的森林,流淌的河流.",
|
| 222 |
+
lines=1,
|
| 223 |
+
max_lines=1 if txt2img_defaults['submit_on_enter'] == 'Yes' else 25,
|
| 224 |
+
value=img2img_defaults['prompt'],
|
| 225 |
+
show_label=False).style()
|
| 226 |
+
|
| 227 |
+
img2img_btn_mask = gr.Button("Generate", variant="primary", visible=False,
|
| 228 |
+
elem_id="img2img_mask_btn")
|
| 229 |
+
img2img_btn_editor = gr.Button("Generate", variant="primary", elem_id="img2img_edit_btn")
|
| 230 |
+
with gr.Row().style(equal_height=False):
|
| 231 |
+
with gr.Column():
|
| 232 |
+
gr.Markdown('#### 输入图像')
|
| 233 |
+
img2img_image_mask = gr.Image(
|
| 234 |
+
value=sample_img2img,
|
| 235 |
+
source="upload",
|
| 236 |
+
interactive=True,
|
| 237 |
+
type="pil", tool="sketch",
|
| 238 |
+
elem_id="img2img_mask",
|
| 239 |
+
image_mode="RGBA"
|
| 240 |
+
)
|
| 241 |
+
img2img_image_editor = gr.Image(
|
| 242 |
+
value=sample_img2img,
|
| 243 |
+
source="upload",
|
| 244 |
+
interactive=True,
|
| 245 |
+
type="pil",
|
| 246 |
+
tool="select",
|
| 247 |
+
visible=False,
|
| 248 |
+
image_mode="RGBA",
|
| 249 |
+
elem_id="img2img_editor"
|
| 250 |
+
)
|
| 251 |
+
|
| 252 |
+
with gr.Tabs():
|
| 253 |
+
with gr.TabItem("编辑设置"):
|
| 254 |
+
with gr.Row():
|
| 255 |
+
# disable Uncrop for now
|
| 256 |
+
choices=["Mask", "Crop", "Uncrop"]
|
| 257 |
+
img2img_image_editor_mode = gr.Radio(choices=["Mask"],
|
| 258 |
+
label="编辑模式",
|
| 259 |
+
value="Mask", elem_id='edit_mode_select',
|
| 260 |
+
visible=True)
|
| 261 |
+
img2img_mask = gr.Radio(choices=["保留mask区域", "生成mask区域"],
|
| 262 |
+
label="Mask 方式", type="index",
|
| 263 |
+
#value=img2img_mask_modes[img2img_defaults['mask_mode']],
|
| 264 |
+
value = "生成mask区域",
|
| 265 |
+
visible=True)
|
| 266 |
+
|
| 267 |
+
img2img_mask_blur_strength = gr.Slider(minimum=1, maximum=10, step=1,
|
| 268 |
+
label="How much blurry should the mask be? (to avoid hard edges)",
|
| 269 |
+
value=3, visible=False)
|
| 270 |
+
|
| 271 |
+
img2img_resize = gr.Radio(label="Resize mode",
|
| 272 |
+
choices=["Just resize", "Crop and resize",
|
| 273 |
+
"Resize and fill"],
|
| 274 |
+
type="index",
|
| 275 |
+
value=img2img_resize_modes[
|
| 276 |
+
img2img_defaults['resize_mode']], visible=False)
|
| 277 |
+
|
| 278 |
+
img2img_painterro_btn = gr.Button("Advanced Editor",visible=False)
|
| 279 |
+
# with gr.TabItem("Hints",visible=False):
|
| 280 |
+
# img2img_help = gr.Markdown(visible=False, value=uifn.help_text)
|
| 281 |
+
|
| 282 |
+
with gr.Column():
|
| 283 |
+
gr.Markdown('#### 编辑后的图片')
|
| 284 |
+
output_img2img_gallery = gr.Gallery(label="Images", elem_id="img2img_gallery_output").style(
|
| 285 |
+
grid=[4, 4, 4])
|
| 286 |
+
img2img_job_ui = job_manager.draw_gradio_ui() if job_manager else None
|
| 287 |
+
with gr.Column(visible=False):
|
| 288 |
+
with gr.Tabs(visible=False):
|
| 289 |
+
with gr.TabItem("", id="img2img_actions_tab",visible=False):
|
| 290 |
+
gr.Markdown("Select an image, then press one of the buttons below")
|
| 291 |
+
with gr.Row():
|
| 292 |
+
output_img2img_copy_to_clipboard_btn = gr.Button("Copy to clipboard")
|
| 293 |
+
output_img2img_copy_to_input_btn = gr.Button("Push to img2img input")
|
| 294 |
+
output_img2img_copy_to_mask_btn = gr.Button("Push to img2img input mask")
|
| 295 |
+
|
| 296 |
+
gr.Markdown("Warning: This will clear your current image and mask settings!")
|
| 297 |
+
with gr.TabItem("", id="img2img_output_info_tab",visible=False):
|
| 298 |
+
output_img2img_params = gr.Textbox(label="Generation parameters")
|
| 299 |
+
with gr.Row():
|
| 300 |
+
output_img2img_copy_params = gr.Button("Copy full parameters").click(
|
| 301 |
+
inputs=output_img2img_params, outputs=[],
|
| 302 |
+
_js='(x) => {navigator.clipboard.writeText(x.replace(": ",":"))}', fn=None,
|
| 303 |
+
show_progress=False)
|
| 304 |
+
output_img2img_seed = gr.Number(label='Seed', interactive=False, visible=False)
|
| 305 |
+
output_img2img_copy_seed = gr.Button("Copy only seed").click(
|
| 306 |
+
inputs=output_img2img_seed, outputs=[],
|
| 307 |
+
_js=call_JS("gradioInputToClipboard"), fn=None, show_progress=False)
|
| 308 |
+
output_img2img_stats = gr.HTML(label='Stats')
|
| 309 |
+
|
| 310 |
+
gr.Markdown('# 编辑设置')
|
| 311 |
+
|
| 312 |
+
with gr.Row():
|
| 313 |
+
with gr.Column():
|
| 314 |
+
img2img_width = gr.Slider(minimum=64, maximum=2048, step=64, label="图片宽度",
|
| 315 |
+
value=img2img_defaults["width"])
|
| 316 |
+
img2img_height = gr.Slider(minimum=64, maximum=2048, step=64, label="图片高度",
|
| 317 |
+
value=img2img_defaults["height"])
|
| 318 |
+
img2img_cfg = gr.Slider(minimum=-40.0, maximum=30.0, step=0.5,
|
| 319 |
+
label='文本引导强度',
|
| 320 |
+
value=img2img_defaults['cfg_scale'], elem_id='cfg_slider')
|
| 321 |
+
img2img_seed = gr.Textbox(label="随机种子", lines=1, max_lines=1,
|
| 322 |
+
value=img2img_defaults["seed"])
|
| 323 |
+
img2img_batch_count = gr.Slider(minimum=1, maximum=50, step=1,
|
| 324 |
+
label='生成数量',
|
| 325 |
+
value=img2img_defaults['n_iter'])
|
| 326 |
+
img2img_dimensions_info_text_box = gr.Textbox(
|
| 327 |
+
label="长宽比设置")
|
| 328 |
+
with gr.Column():
|
| 329 |
+
img2img_steps = gr.Slider(minimum=1, maximum=250, step=1, label="采样步数",
|
| 330 |
+
value=img2img_defaults['ddim_steps'])
|
| 331 |
+
|
| 332 |
+
img2img_sampling = gr.Dropdown(label='采样方式',
|
| 333 |
+
choices=["DDIM", 'k_dpm_2_a', 'k_dpm_2', 'k_euler_a', 'k_euler',
|
| 334 |
+
'k_heun', 'k_lms'],
|
| 335 |
+
value=img2img_defaults['sampler_name'])
|
| 336 |
+
|
| 337 |
+
img2img_denoising = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label='Denoising Strength',
|
| 338 |
+
value=img2img_defaults['denoising_strength'],visible=False)
|
| 339 |
+
|
| 340 |
+
img2img_toggles = gr.CheckboxGroup(label='', choices=img2img_toggles,
|
| 341 |
+
value=img2img_toggle_defaults, type="index",visible=False)
|
| 342 |
+
|
| 343 |
+
img2img_realesrgan_model_name = gr.Dropdown(label='RealESRGAN model',
|
| 344 |
+
choices=['RealESRGAN_x4plus',
|
| 345 |
+
'RealESRGAN_x4plus_anime_6B'],
|
| 346 |
+
value='RealESRGAN_x4plus',
|
| 347 |
+
visible=RealESRGAN is not None) # TODO: Feels like I shouldnt slot it in here.
|
| 348 |
+
|
| 349 |
+
img2img_embeddings = gr.File(label="Embeddings file for textual inversion",
|
| 350 |
+
visible=show_embeddings)
|
| 351 |
+
|
| 352 |
+
img2img_image_editor_mode.change(
|
| 353 |
+
uifn.change_image_editor_mode,
|
| 354 |
+
[img2img_image_editor_mode,
|
| 355 |
+
img2img_image_editor,
|
| 356 |
+
img2img_image_mask,
|
| 357 |
+
img2img_resize,
|
| 358 |
+
img2img_width,
|
| 359 |
+
img2img_height
|
| 360 |
+
],
|
| 361 |
+
[img2img_image_editor, img2img_image_mask, img2img_btn_editor, img2img_btn_mask,
|
| 362 |
+
img2img_painterro_btn, img2img_mask, img2img_mask_blur_strength]
|
| 363 |
+
)
|
| 364 |
+
|
| 365 |
+
# img2img_image_editor_mode.change(
|
| 366 |
+
# uifn.update_image_mask,
|
| 367 |
+
# [img2img_image_editor, img2img_resize, img2img_width, img2img_height],
|
| 368 |
+
# img2img_image_mask
|
| 369 |
+
# )
|
| 370 |
+
|
| 371 |
+
# output_txt2img_copy_to_input_btn.click(
|
| 372 |
+
# uifn.copy_img_to_input,
|
| 373 |
+
# [output_txt2img_gallery],
|
| 374 |
+
# [img2img_image_editor, img2img_image_mask, tabs],
|
| 375 |
+
# _js=call_JS("moveImageFromGallery",
|
| 376 |
+
# fromId="txt2img_gallery_output",
|
| 377 |
+
# toId="img2img_editor")
|
| 378 |
+
# )
|
| 379 |
+
|
| 380 |
+
output_img2img_copy_to_input_btn.click(
|
| 381 |
+
uifn.copy_img_to_edit,
|
| 382 |
+
[output_img2img_gallery],
|
| 383 |
+
[img2img_image_editor, tabs, img2img_image_editor_mode],
|
| 384 |
+
_js=call_JS("moveImageFromGallery",
|
| 385 |
+
fromId="img2img_gallery_output",
|
| 386 |
+
toId="img2img_editor")
|
| 387 |
+
)
|
| 388 |
+
output_img2img_copy_to_mask_btn.click(
|
| 389 |
+
uifn.copy_img_to_mask,
|
| 390 |
+
[output_img2img_gallery],
|
| 391 |
+
[img2img_image_mask, tabs, img2img_image_editor_mode],
|
| 392 |
+
_js=call_JS("moveImageFromGallery",
|
| 393 |
+
fromId="img2img_gallery_output",
|
| 394 |
+
toId="img2img_editor")
|
| 395 |
+
)
|
| 396 |
+
|
| 397 |
+
output_img2img_copy_to_clipboard_btn.click(fn=None, inputs=output_img2img_gallery, outputs=[],
|
| 398 |
+
_js=call_JS("copyImageFromGalleryToClipboard",
|
| 399 |
+
fromId="img2img_gallery_output")
|
| 400 |
+
)
|
| 401 |
+
|
| 402 |
+
img2img_func = img2img
|
| 403 |
+
img2img_inputs = [img2img_prompt, img2img_image_editor_mode, img2img_mask,
|
| 404 |
+
img2img_mask_blur_strength, img2img_steps, img2img_sampling, img2img_toggles,
|
| 405 |
+
img2img_realesrgan_model_name, img2img_batch_count, img2img_cfg,
|
| 406 |
+
img2img_denoising, img2img_seed, img2img_height, img2img_width, img2img_resize,
|
| 407 |
+
img2img_image_editor, img2img_image_mask, img2img_embeddings]
|
| 408 |
+
img2img_outputs = [output_img2img_gallery, output_img2img_seed, output_img2img_params,
|
| 409 |
+
output_img2img_stats]
|
| 410 |
+
|
| 411 |
+
# If a JobManager was passed in then wrap the Generate functions
|
| 412 |
+
if img2img_job_ui:
|
| 413 |
+
img2img_func, img2img_inputs, img2img_outputs = img2img_job_ui.wrap_func(
|
| 414 |
+
func=img2img_func,
|
| 415 |
+
inputs=img2img_inputs,
|
| 416 |
+
outputs=img2img_outputs,
|
| 417 |
+
)
|
| 418 |
+
|
| 419 |
+
img2img_btn_mask.click(
|
| 420 |
+
img2img_func,
|
| 421 |
+
img2img_inputs,
|
| 422 |
+
img2img_outputs
|
| 423 |
+
)
|
| 424 |
+
|
| 425 |
+
def img2img_submit_params():
|
| 426 |
+
# print([img2img_prompt, img2img_image_editor_mode, img2img_mask,
|
| 427 |
+
# img2img_mask_blur_strength, img2img_steps, img2img_sampling, img2img_toggles,
|
| 428 |
+
# img2img_realesrgan_model_name, img2img_batch_count, img2img_cfg,
|
| 429 |
+
# img2img_denoising, img2img_seed, img2img_height, img2img_width, img2img_resize,
|
| 430 |
+
# img2img_image_editor, img2img_image_mask, img2img_embeddings])
|
| 431 |
+
return (img2img_func,
|
| 432 |
+
img2img_inputs,
|
| 433 |
+
img2img_outputs)
|
| 434 |
+
|
| 435 |
+
img2img_btn_editor.click(*img2img_submit_params())
|
| 436 |
+
|
| 437 |
+
# GENERATE ON ENTER
|
| 438 |
+
img2img_prompt.submit(None, None, None,
|
| 439 |
+
_js=call_JS("clickFirstVisibleButton",
|
| 440 |
+
rowId="prompt_row"))
|
| 441 |
+
|
| 442 |
+
img2img_painterro_btn.click(None,
|
| 443 |
+
[img2img_image_editor, img2img_image_mask, img2img_image_editor_mode],
|
| 444 |
+
[img2img_image_editor, img2img_image_mask],
|
| 445 |
+
_js=call_JS("Painterro.init", toId="img2img_editor")
|
| 446 |
+
)
|
| 447 |
+
|
| 448 |
+
img2img_width.change(fn=uifn.update_dimensions_info, inputs=[img2img_width, img2img_height],
|
| 449 |
+
outputs=img2img_dimensions_info_text_box)
|
| 450 |
+
img2img_height.change(fn=uifn.update_dimensions_info, inputs=[img2img_width, img2img_height],
|
| 451 |
+
outputs=img2img_dimensions_info_text_box)
|
| 452 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 453 |
gr.HTML(read_content("footer.html"))
|
| 454 |
# gr.Image('./contributors.png')
|
| 455 |
|