Commit
•
6fd0800
1
Parent(s):
93fe395
Upload 2 files
Browse files- ai_image_creation.zip +2 -2
- app.py +230 -34
ai_image_creation.zip
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4b5a819b62acd92c6a0b6a9e40582bac0b4dfd5a9cd9a2b5bbf1dedc0565c7fc
|
3 |
+
size 25590
|
app.py
CHANGED
@@ -1371,6 +1371,157 @@ def update_log_progress ():
|
|
1371 |
|
1372 |
|
1373 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1374 |
|
1375 |
#####################
|
1376 |
#
|
@@ -1382,6 +1533,12 @@ def update_log_progress ():
|
|
1382 |
|
1383 |
def before_create_image_function ():
|
1384 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1385 |
output_text_field_update = gr.Textbox(
|
1386 |
visible = False
|
1387 |
)
|
@@ -1392,16 +1549,10 @@ def before_create_image_function ():
|
|
1392 |
every = 1
|
1393 |
)
|
1394 |
|
1395 |
-
generate_image_btn_update = gr.Button(
|
1396 |
-
value = "Generating...",
|
1397 |
-
variant = "secondary",
|
1398 |
-
interactive = False
|
1399 |
-
)
|
1400 |
-
|
1401 |
return {
|
|
|
1402 |
output_text_field: output_text_field_update,
|
1403 |
-
log_text_field: log_text_field_update
|
1404 |
-
generate_image_btn: generate_image_btn_update
|
1405 |
}
|
1406 |
|
1407 |
|
@@ -1420,6 +1571,12 @@ def before_create_image_function ():
|
|
1420 |
|
1421 |
def after_create_image_function ():
|
1422 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1423 |
output_text_field_update = gr.Textbox(
|
1424 |
visible = True
|
1425 |
)
|
@@ -1430,16 +1587,13 @@ def after_create_image_function ():
|
|
1430 |
every = None
|
1431 |
)
|
1432 |
|
1433 |
-
|
1434 |
-
value = "Generate",
|
1435 |
-
variant = "primary",
|
1436 |
-
interactive = True
|
1437 |
-
)
|
1438 |
|
1439 |
return {
|
|
|
1440 |
output_text_field: output_text_field_update,
|
1441 |
log_text_field: log_text_field_update,
|
1442 |
-
|
1443 |
}
|
1444 |
|
1445 |
|
@@ -3035,12 +3189,6 @@ with gr.Blocks(
|
|
3035 |
step = 0.01
|
3036 |
)
|
3037 |
|
3038 |
-
with gr.Row():
|
3039 |
-
|
3040 |
-
refiner_steps_text_field = gr.HTML(
|
3041 |
-
value = ""
|
3042 |
-
)
|
3043 |
-
|
3044 |
with gr.Row():
|
3045 |
|
3046 |
refining_use_denoising_start_in_base_model_when_using_refiner_field = gr.Checkbox(
|
@@ -3285,24 +3433,24 @@ with gr.Blocks(
|
|
3285 |
|
3286 |
with gr.Row():
|
3287 |
|
3288 |
-
seed_selection_option = gr.Slider(
|
3289 |
-
label = "Seed (0 is random):",
|
3290 |
-
minimum = 0,
|
3291 |
-
maximum = default_seed_maximum,
|
3292 |
-
value = default_seed_value,
|
3293 |
-
step = 1,
|
3294 |
-
interactive = True
|
3295 |
-
)
|
3296 |
-
|
3297 |
if make_seed_selection_a_textbox == 1:
|
3298 |
|
3299 |
-
|
3300 |
label = "Seed (0 is random; " + str(default_seed_maximum) + " max):",
|
3301 |
value = "0",
|
3302 |
interactive = True
|
3303 |
)
|
3304 |
|
3305 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3306 |
|
3307 |
|
3308 |
|
@@ -3489,13 +3637,40 @@ with gr.Blocks(
|
|
3489 |
fn = before_create_image_function,
|
3490 |
inputs = [],
|
3491 |
outputs = [
|
|
|
3492 |
output_image_field,
|
3493 |
output_text_field,
|
3494 |
-
log_text_field
|
3495 |
-
generate_image_btn
|
3496 |
],
|
3497 |
show_progress = "minimal",
|
3498 |
queue = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3499 |
).then(
|
3500 |
fn = create_image_function,
|
3501 |
inputs = [
|
@@ -3534,9 +3709,30 @@ with gr.Blocks(
|
|
3534 |
fn = after_create_image_function,
|
3535 |
inputs = [],
|
3536 |
outputs = [
|
|
|
3537 |
output_text_field,
|
3538 |
log_text_field,
|
3539 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3540 |
],
|
3541 |
queue = False
|
3542 |
)
|
|
|
1371 |
|
1372 |
|
1373 |
|
1374 |
+
#####################
|
1375 |
+
#
|
1376 |
+
# Toggle Interactivity During Image Creation
|
1377 |
+
#
|
1378 |
+
#
|
1379 |
+
#
|
1380 |
+
#####################
|
1381 |
+
|
1382 |
+
def toggle_interactivity_during_image_creation (
|
1383 |
+
interactivity
|
1384 |
+
):
|
1385 |
+
|
1386 |
+
if script_being_run_on_hugging_face == 1:
|
1387 |
+
|
1388 |
+
prompt_field_update = gr.Textbox(
|
1389 |
+
interactive = interactivity,
|
1390 |
+
)
|
1391 |
+
|
1392 |
+
negative_prompt_field_update = gr.Textbox(
|
1393 |
+
interactive = interactivity
|
1394 |
+
)
|
1395 |
+
|
1396 |
+
refining_selection_default_config_field_update = gr.Radio(
|
1397 |
+
interactive = interactivity
|
1398 |
+
)
|
1399 |
+
|
1400 |
+
refining_denoise_start_for_default_config_field_update = gr.Slider(
|
1401 |
+
interactive = interactivity
|
1402 |
+
)
|
1403 |
+
|
1404 |
+
refining_use_denoising_start_in_base_model_when_using_refiner_field_update = gr.Checkbox(
|
1405 |
+
interactive = interactivity
|
1406 |
+
)
|
1407 |
+
|
1408 |
+
refining_base_model_output_to_refiner_is_in_latent_space_field_update = gr.Checkbox(
|
1409 |
+
interactive = interactivity
|
1410 |
+
)
|
1411 |
+
|
1412 |
+
refining_selection_online_config_normal_field_update = gr.Radio(
|
1413 |
+
interactive = interactivity
|
1414 |
+
)
|
1415 |
+
|
1416 |
+
refining_selection_online_config_automatically_selected_field_update = gr.Radio(
|
1417 |
+
interactive = interactivity
|
1418 |
+
)
|
1419 |
+
|
1420 |
+
refining_denoise_start_for_online_config_field_update = gr.Slider(
|
1421 |
+
interactive = interactivity
|
1422 |
+
)
|
1423 |
+
|
1424 |
+
refining_number_of_iterations_for_online_config_field_update = gr.Slider(
|
1425 |
+
interactive = interactivity
|
1426 |
+
)
|
1427 |
+
|
1428 |
+
upscaling_selection_field_update = gr.Radio(
|
1429 |
+
interactive = interactivity
|
1430 |
+
)
|
1431 |
+
|
1432 |
+
upscaling_num_inference_steps_field_update = gr.Slider(
|
1433 |
+
interactive = interactivity
|
1434 |
+
)
|
1435 |
+
|
1436 |
+
base_model_field_update = gr.Dropdown(
|
1437 |
+
interactive = interactivity
|
1438 |
+
)
|
1439 |
+
|
1440 |
+
model_configuration_field_update = gr.Dropdown(
|
1441 |
+
interactive = interactivity
|
1442 |
+
)
|
1443 |
+
|
1444 |
+
image_width_field_update = gr.Slider(
|
1445 |
+
interactive = interactivity
|
1446 |
+
)
|
1447 |
+
|
1448 |
+
image_height_field_update = gr.Slider(
|
1449 |
+
interactive = interactivity
|
1450 |
+
)
|
1451 |
+
|
1452 |
+
base_model_num_inference_steps_field_update = gr.Slider(
|
1453 |
+
interactive = interactivity
|
1454 |
+
)
|
1455 |
+
|
1456 |
+
base_model_num_inference_steps_field_for_sdxl_turbo_field_update = gr.Slider(
|
1457 |
+
interactive = interactivity
|
1458 |
+
)
|
1459 |
+
|
1460 |
+
guidance_scale_field_update = gr.Slider(
|
1461 |
+
interactive = interactivity
|
1462 |
+
)
|
1463 |
+
|
1464 |
+
if make_seed_selection_a_textbox == 1:
|
1465 |
+
|
1466 |
+
seed_field_update = gr.Textbox(
|
1467 |
+
interactive = interactivity
|
1468 |
+
)
|
1469 |
+
|
1470 |
+
else:
|
1471 |
+
|
1472 |
+
seed_field_update = gr.Slider(
|
1473 |
+
interactive = interactivity
|
1474 |
+
)
|
1475 |
+
|
1476 |
+
return {
|
1477 |
+
# prompt_field: prompt_field_update,
|
1478 |
+
# negative_prompt_field: negative_prompt_field_update,
|
1479 |
+
refining_selection_default_config_field: refining_selection_default_config_field_update,
|
1480 |
+
refining_denoise_start_for_default_config_field: refining_denoise_start_for_default_config_field_update,
|
1481 |
+
refining_use_denoising_start_in_base_model_when_using_refiner_field: refining_use_denoising_start_in_base_model_when_using_refiner_field_update,
|
1482 |
+
refining_base_model_output_to_refiner_is_in_latent_space_field: refining_base_model_output_to_refiner_is_in_latent_space_field_update,
|
1483 |
+
refining_selection_online_config_normal_field: refining_selection_online_config_normal_field_update,
|
1484 |
+
refining_selection_online_config_automatically_selected_field: refining_selection_online_config_automatically_selected_field_update,
|
1485 |
+
refining_denoise_start_for_online_config_field: refining_denoise_start_for_online_config_field_update,
|
1486 |
+
refining_number_of_iterations_for_online_config_field: refining_number_of_iterations_for_online_config_field_update,
|
1487 |
+
upscaling_selection_field: upscaling_selection_field_update,
|
1488 |
+
upscaling_num_inference_steps_field: upscaling_num_inference_steps_field_update,
|
1489 |
+
base_model_field: base_model_field_update,
|
1490 |
+
model_configuration_field: model_configuration_field_update,
|
1491 |
+
image_width_field: image_width_field_update,
|
1492 |
+
image_height_field: image_height_field_update,
|
1493 |
+
base_model_num_inference_steps_field: base_model_num_inference_steps_field_update,
|
1494 |
+
base_model_num_inference_steps_field_for_sdxl_turbo_field: base_model_num_inference_steps_field_for_sdxl_turbo_field_update,
|
1495 |
+
guidance_scale_field: guidance_scale_field_update,
|
1496 |
+
seed_field: seed_field_update
|
1497 |
+
}
|
1498 |
+
|
1499 |
+
|
1500 |
+
|
1501 |
+
|
1502 |
+
|
1503 |
+
|
1504 |
+
|
1505 |
+
#####################
|
1506 |
+
#
|
1507 |
+
# Disable Form Function
|
1508 |
+
#
|
1509 |
+
# Disable most form inputs during image generation
|
1510 |
+
#
|
1511 |
+
#####################
|
1512 |
+
|
1513 |
+
def disable_form_function ():
|
1514 |
+
|
1515 |
+
toggled_interactivity_fields_kwargs = toggle_interactivity_during_image_creation(False)
|
1516 |
+
|
1517 |
+
return {
|
1518 |
+
**toggled_interactivity_fields_kwargs
|
1519 |
+
}
|
1520 |
+
|
1521 |
+
|
1522 |
+
|
1523 |
+
|
1524 |
+
|
1525 |
|
1526 |
#####################
|
1527 |
#
|
|
|
1533 |
|
1534 |
def before_create_image_function ():
|
1535 |
|
1536 |
+
generate_image_btn_update = gr.Button(
|
1537 |
+
value = "Generating...",
|
1538 |
+
variant = "secondary",
|
1539 |
+
interactive = False
|
1540 |
+
)
|
1541 |
+
|
1542 |
output_text_field_update = gr.Textbox(
|
1543 |
visible = False
|
1544 |
)
|
|
|
1549 |
every = 1
|
1550 |
)
|
1551 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1552 |
return {
|
1553 |
+
generate_image_btn: generate_image_btn_update,
|
1554 |
output_text_field: output_text_field_update,
|
1555 |
+
log_text_field: log_text_field_update
|
|
|
1556 |
}
|
1557 |
|
1558 |
|
|
|
1571 |
|
1572 |
def after_create_image_function ():
|
1573 |
|
1574 |
+
generate_image_btn_update = gr.Button(
|
1575 |
+
value = "Generate",
|
1576 |
+
variant = "primary",
|
1577 |
+
interactive = True
|
1578 |
+
)
|
1579 |
+
|
1580 |
output_text_field_update = gr.Textbox(
|
1581 |
visible = True
|
1582 |
)
|
|
|
1587 |
every = None
|
1588 |
)
|
1589 |
|
1590 |
+
toggled_interactivity_fields_kwargs = toggle_interactivity_during_image_creation(True)
|
|
|
|
|
|
|
|
|
1591 |
|
1592 |
return {
|
1593 |
+
generate_image_btn: generate_image_btn_update,
|
1594 |
output_text_field: output_text_field_update,
|
1595 |
log_text_field: log_text_field_update,
|
1596 |
+
**toggled_interactivity_fields_kwargs
|
1597 |
}
|
1598 |
|
1599 |
|
|
|
3189 |
step = 0.01
|
3190 |
)
|
3191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
3192 |
with gr.Row():
|
3193 |
|
3194 |
refining_use_denoising_start_in_base_model_when_using_refiner_field = gr.Checkbox(
|
|
|
3433 |
|
3434 |
with gr.Row():
|
3435 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3436 |
if make_seed_selection_a_textbox == 1:
|
3437 |
|
3438 |
+
seed_field = gr.Textbox(
|
3439 |
label = "Seed (0 is random; " + str(default_seed_maximum) + " max):",
|
3440 |
value = "0",
|
3441 |
interactive = True
|
3442 |
)
|
3443 |
|
3444 |
+
else:
|
3445 |
+
|
3446 |
+
seed_field = gr.Slider(
|
3447 |
+
label = "Seed (0 is random):",
|
3448 |
+
minimum = 0,
|
3449 |
+
maximum = default_seed_maximum,
|
3450 |
+
value = default_seed_value,
|
3451 |
+
step = 1,
|
3452 |
+
interactive = True
|
3453 |
+
)
|
3454 |
|
3455 |
|
3456 |
|
|
|
3637 |
fn = before_create_image_function,
|
3638 |
inputs = [],
|
3639 |
outputs = [
|
3640 |
+
generate_image_btn,
|
3641 |
output_image_field,
|
3642 |
output_text_field,
|
3643 |
+
log_text_field
|
|
|
3644 |
],
|
3645 |
show_progress = "minimal",
|
3646 |
queue = True
|
3647 |
+
).then(
|
3648 |
+
fn = disable_form_function,
|
3649 |
+
inputs = [],
|
3650 |
+
outputs = [
|
3651 |
+
prompt_field,
|
3652 |
+
negative_prompt_field,
|
3653 |
+
refining_selection_default_config_field,
|
3654 |
+
refining_denoise_start_for_default_config_field,
|
3655 |
+
refining_use_denoising_start_in_base_model_when_using_refiner_field,
|
3656 |
+
refining_base_model_output_to_refiner_is_in_latent_space_field,
|
3657 |
+
refining_selection_online_config_normal_field,
|
3658 |
+
refining_selection_online_config_automatically_selected_field,
|
3659 |
+
refining_denoise_start_for_online_config_field,
|
3660 |
+
refining_number_of_iterations_for_online_config_field,
|
3661 |
+
upscaling_selection_field,
|
3662 |
+
upscaling_num_inference_steps_field,
|
3663 |
+
base_model_field,
|
3664 |
+
model_configuration_field,
|
3665 |
+
image_width_field,
|
3666 |
+
image_height_field,
|
3667 |
+
base_model_num_inference_steps_field,
|
3668 |
+
base_model_num_inference_steps_field_for_sdxl_turbo_field,
|
3669 |
+
guidance_scale_field,
|
3670 |
+
seed_field
|
3671 |
+
],
|
3672 |
+
show_progress = "hidden",
|
3673 |
+
queue = False
|
3674 |
).then(
|
3675 |
fn = create_image_function,
|
3676 |
inputs = [
|
|
|
3709 |
fn = after_create_image_function,
|
3710 |
inputs = [],
|
3711 |
outputs = [
|
3712 |
+
generate_image_btn,
|
3713 |
output_text_field,
|
3714 |
log_text_field,
|
3715 |
+
|
3716 |
+
prompt_field,
|
3717 |
+
negative_prompt_field,
|
3718 |
+
refining_selection_default_config_field,
|
3719 |
+
refining_denoise_start_for_default_config_field,
|
3720 |
+
refining_use_denoising_start_in_base_model_when_using_refiner_field,
|
3721 |
+
refining_base_model_output_to_refiner_is_in_latent_space_field,
|
3722 |
+
refining_selection_online_config_normal_field,
|
3723 |
+
refining_selection_online_config_automatically_selected_field,
|
3724 |
+
refining_denoise_start_for_online_config_field,
|
3725 |
+
refining_number_of_iterations_for_online_config_field,
|
3726 |
+
upscaling_selection_field,
|
3727 |
+
upscaling_num_inference_steps_field,
|
3728 |
+
base_model_field,
|
3729 |
+
model_configuration_field,
|
3730 |
+
image_width_field,
|
3731 |
+
image_height_field,
|
3732 |
+
base_model_num_inference_steps_field,
|
3733 |
+
base_model_num_inference_steps_field_for_sdxl_turbo_field,
|
3734 |
+
guidance_scale_field,
|
3735 |
+
seed_field
|
3736 |
],
|
3737 |
queue = False
|
3738 |
)
|