Spaces:
Paused
Paused
Upload 8 files
Browse files- app.py +28 -30
- controlnet/controlnet_canny.py +1 -1
- controlnet/controlnet_depth.py +1 -1
- controlnet/controlnet_hed.py +2 -5
- controlnet/controlnet_mlsd.py +2 -5
- controlnet/controlnet_pose.py +1 -1
- controlnet/controlnet_scribble.py +2 -3
- controlnet/controlnet_seg.py +1 -1
app.py
CHANGED
|
@@ -3,13 +3,13 @@ from utils.image2image import stable_diffusion_img2img
|
|
| 3 |
from utils.text2image import stable_diffusion_text2img
|
| 4 |
from utils.inpaint import stable_diffusion_inpaint
|
| 5 |
|
| 6 |
-
from controlnet.controlnet_canny import
|
| 7 |
-
from controlnet.controlnet_depth import
|
| 8 |
-
from controlnet.controlnet_hed import
|
| 9 |
-
from controlnet.controlnet_mlsd import
|
| 10 |
-
from controlnet.controlnet_pose import
|
| 11 |
-
from controlnet.controlnet_scribble import
|
| 12 |
-
from controlnet.controlnet_seg import
|
| 13 |
|
| 14 |
|
| 15 |
import gradio as gr
|
|
@@ -39,7 +39,7 @@ stable_negative_prompt_list = [
|
|
| 39 |
]
|
| 40 |
app = gr.Blocks()
|
| 41 |
with app:
|
| 42 |
-
gr.Markdown("# **<h2 align='center'>Stable Diffusion
|
| 43 |
gr.Markdown(
|
| 44 |
"""
|
| 45 |
<h5 style='text-align: center'>
|
|
@@ -190,7 +190,6 @@ with app:
|
|
| 190 |
|
| 191 |
inpaint_predict = gr.Button(value='Generator')
|
| 192 |
|
| 193 |
-
|
| 194 |
with gr.Tab('ControlNet'):
|
| 195 |
with gr.Tab('Canny'):
|
| 196 |
controlnet_canny_image_file = gr.Image(label='Image')
|
|
@@ -236,14 +235,14 @@ with app:
|
|
| 236 |
controlnet_hed_image_file = gr.Image(label='Image')
|
| 237 |
|
| 238 |
controlnet_hed_model_id = gr.Dropdown(
|
| 239 |
-
choices=
|
| 240 |
-
value=
|
| 241 |
label='Stable Model Id'
|
| 242 |
)
|
| 243 |
|
| 244 |
controlnet_hed_prompt = gr.Textbox(
|
| 245 |
lines=1,
|
| 246 |
-
value=
|
| 247 |
label='Prompt'
|
| 248 |
)
|
| 249 |
|
|
@@ -276,8 +275,8 @@ with app:
|
|
| 276 |
controlnet_mlsd_image_file = gr.Image(label='Image')
|
| 277 |
|
| 278 |
controlnet_mlsd_model_id = gr.Dropdown(
|
| 279 |
-
choices=
|
| 280 |
-
value=
|
| 281 |
label='Stable Model Id'
|
| 282 |
)
|
| 283 |
|
|
@@ -316,8 +315,8 @@ with app:
|
|
| 316 |
controlnet_seg_image_file = gr.Image(label='Image')
|
| 317 |
|
| 318 |
controlnet_seg_model_id = gr.Dropdown(
|
| 319 |
-
choices=
|
| 320 |
-
value=
|
| 321 |
label='Stable Model Id'
|
| 322 |
)
|
| 323 |
|
|
@@ -356,8 +355,8 @@ with app:
|
|
| 356 |
controlnet_depth_image_file = gr.Image(label='Image')
|
| 357 |
|
| 358 |
controlnet_depth_model_id = gr.Dropdown(
|
| 359 |
-
choices=
|
| 360 |
-
value=
|
| 361 |
label='Stable Model Id'
|
| 362 |
)
|
| 363 |
|
|
@@ -396,8 +395,8 @@ with app:
|
|
| 396 |
controlnet_scribble_image_file = gr.Image(label='Image')
|
| 397 |
|
| 398 |
controlnet_scribble_model_id = gr.Dropdown(
|
| 399 |
-
choices=
|
| 400 |
-
value=
|
| 401 |
label='Stable Model Id'
|
| 402 |
)
|
| 403 |
|
|
@@ -436,8 +435,8 @@ with app:
|
|
| 436 |
controlnet_pose_image_file = gr.Image(label='Image')
|
| 437 |
|
| 438 |
controlnet_pose_model_id = gr.Dropdown(
|
| 439 |
-
choices=
|
| 440 |
-
value=
|
| 441 |
label='Stable Model Id'
|
| 442 |
)
|
| 443 |
|
|
@@ -516,9 +515,8 @@ with app:
|
|
| 516 |
outputs = [output_image],
|
| 517 |
)
|
| 518 |
|
| 519 |
-
|
| 520 |
controlnet_canny_predict.click(
|
| 521 |
-
fn =
|
| 522 |
inputs = [
|
| 523 |
controlnet_canny_image_file,
|
| 524 |
controlnet_canny_model_id,
|
|
@@ -531,7 +529,7 @@ with app:
|
|
| 531 |
)
|
| 532 |
|
| 533 |
controlnet_hed_predict.click(
|
| 534 |
-
fn =
|
| 535 |
inputs = [
|
| 536 |
controlnet_hed_image_file,
|
| 537 |
controlnet_hed_model_id,
|
|
@@ -544,7 +542,7 @@ with app:
|
|
| 544 |
)
|
| 545 |
|
| 546 |
controlnet_mlsd_predict.click(
|
| 547 |
-
fn =
|
| 548 |
inputs = [
|
| 549 |
controlnet_mlsd_image_file,
|
| 550 |
controlnet_mlsd_model_id,
|
|
@@ -557,7 +555,7 @@ with app:
|
|
| 557 |
)
|
| 558 |
|
| 559 |
controlnet_seg_predict.click(
|
| 560 |
-
fn =
|
| 561 |
inputs = [
|
| 562 |
controlnet_seg_image_file,
|
| 563 |
controlnet_seg_model_id,
|
|
@@ -570,7 +568,7 @@ with app:
|
|
| 570 |
)
|
| 571 |
|
| 572 |
controlnet_depth_predict.click(
|
| 573 |
-
fn =
|
| 574 |
inputs = [
|
| 575 |
controlnet_depth_image_file,
|
| 576 |
controlnet_depth_model_id,
|
|
@@ -583,7 +581,7 @@ with app:
|
|
| 583 |
)
|
| 584 |
|
| 585 |
controlnet_scribble_predict.click(
|
| 586 |
-
fn =
|
| 587 |
inputs = [
|
| 588 |
controlnet_scribble_image_file,
|
| 589 |
controlnet_scribble_model_id,
|
|
@@ -596,7 +594,7 @@ with app:
|
|
| 596 |
)
|
| 597 |
|
| 598 |
controlnet_pose_predict.click(
|
| 599 |
-
fn =
|
| 600 |
inputs = [
|
| 601 |
controlnet_pose_image_file,
|
| 602 |
controlnet_pose_model_id,
|
|
|
|
| 3 |
from utils.text2image import stable_diffusion_text2img
|
| 4 |
from utils.inpaint import stable_diffusion_inpaint
|
| 5 |
|
| 6 |
+
from controlnet.controlnet_canny import stable_diffusion_controlnet_canny
|
| 7 |
+
from controlnet.controlnet_depth import stable_diffusion_controlnet_depth
|
| 8 |
+
from controlnet.controlnet_hed import stable_diffusion_controlnet_hed
|
| 9 |
+
from controlnet.controlnet_mlsd import stable_diffusion_controlnet_mlsd
|
| 10 |
+
from controlnet.controlnet_pose import stable_diffusion_controlnet_pose
|
| 11 |
+
from controlnet.controlnet_scribble import stable_diffusion_controlnet_scribble
|
| 12 |
+
from controlnet.controlnet_seg import stable_diffusion_controlnet_seg
|
| 13 |
|
| 14 |
|
| 15 |
import gradio as gr
|
|
|
|
| 39 |
]
|
| 40 |
app = gr.Blocks()
|
| 41 |
with app:
|
| 42 |
+
gr.Markdown("# **<h2 align='center'>Stable Diffusion WebUI<h2>**")
|
| 43 |
gr.Markdown(
|
| 44 |
"""
|
| 45 |
<h5 style='text-align: center'>
|
|
|
|
| 190 |
|
| 191 |
inpaint_predict = gr.Button(value='Generator')
|
| 192 |
|
|
|
|
| 193 |
with gr.Tab('ControlNet'):
|
| 194 |
with gr.Tab('Canny'):
|
| 195 |
controlnet_canny_image_file = gr.Image(label='Image')
|
|
|
|
| 235 |
controlnet_hed_image_file = gr.Image(label='Image')
|
| 236 |
|
| 237 |
controlnet_hed_model_id = gr.Dropdown(
|
| 238 |
+
choices=stable_model_list,
|
| 239 |
+
value=stable_model_list[0],
|
| 240 |
label='Stable Model Id'
|
| 241 |
)
|
| 242 |
|
| 243 |
controlnet_hed_prompt = gr.Textbox(
|
| 244 |
lines=1,
|
| 245 |
+
value=stable_model_list[0],
|
| 246 |
label='Prompt'
|
| 247 |
)
|
| 248 |
|
|
|
|
| 275 |
controlnet_mlsd_image_file = gr.Image(label='Image')
|
| 276 |
|
| 277 |
controlnet_mlsd_model_id = gr.Dropdown(
|
| 278 |
+
choices=stable_model_list,
|
| 279 |
+
value=stable_model_list[0],
|
| 280 |
label='Stable Model Id'
|
| 281 |
)
|
| 282 |
|
|
|
|
| 315 |
controlnet_seg_image_file = gr.Image(label='Image')
|
| 316 |
|
| 317 |
controlnet_seg_model_id = gr.Dropdown(
|
| 318 |
+
choices=stable_model_list,
|
| 319 |
+
value=stable_model_list[0],
|
| 320 |
label='Stable Model Id'
|
| 321 |
)
|
| 322 |
|
|
|
|
| 355 |
controlnet_depth_image_file = gr.Image(label='Image')
|
| 356 |
|
| 357 |
controlnet_depth_model_id = gr.Dropdown(
|
| 358 |
+
choices=stable_model_list,
|
| 359 |
+
value=stable_model_list[0],
|
| 360 |
label='Stable Model Id'
|
| 361 |
)
|
| 362 |
|
|
|
|
| 395 |
controlnet_scribble_image_file = gr.Image(label='Image')
|
| 396 |
|
| 397 |
controlnet_scribble_model_id = gr.Dropdown(
|
| 398 |
+
choices=stable_model_list,
|
| 399 |
+
value=stable_model_list[0],
|
| 400 |
label='Stable Model Id'
|
| 401 |
)
|
| 402 |
|
|
|
|
| 435 |
controlnet_pose_image_file = gr.Image(label='Image')
|
| 436 |
|
| 437 |
controlnet_pose_model_id = gr.Dropdown(
|
| 438 |
+
choices=stable_model_list,
|
| 439 |
+
value=stable_model_list[0],
|
| 440 |
label='Stable Model Id'
|
| 441 |
)
|
| 442 |
|
|
|
|
| 515 |
outputs = [output_image],
|
| 516 |
)
|
| 517 |
|
|
|
|
| 518 |
controlnet_canny_predict.click(
|
| 519 |
+
fn = stable_diffusion_controlnet_canny,
|
| 520 |
inputs = [
|
| 521 |
controlnet_canny_image_file,
|
| 522 |
controlnet_canny_model_id,
|
|
|
|
| 529 |
)
|
| 530 |
|
| 531 |
controlnet_hed_predict.click(
|
| 532 |
+
fn = stable_diffusion_controlnet_hed,
|
| 533 |
inputs = [
|
| 534 |
controlnet_hed_image_file,
|
| 535 |
controlnet_hed_model_id,
|
|
|
|
| 542 |
)
|
| 543 |
|
| 544 |
controlnet_mlsd_predict.click(
|
| 545 |
+
fn = stable_diffusion_controlnet_mlsd,
|
| 546 |
inputs = [
|
| 547 |
controlnet_mlsd_image_file,
|
| 548 |
controlnet_mlsd_model_id,
|
|
|
|
| 555 |
)
|
| 556 |
|
| 557 |
controlnet_seg_predict.click(
|
| 558 |
+
fn = stable_diffusion_controlnet_seg,
|
| 559 |
inputs = [
|
| 560 |
controlnet_seg_image_file,
|
| 561 |
controlnet_seg_model_id,
|
|
|
|
| 568 |
)
|
| 569 |
|
| 570 |
controlnet_depth_predict.click(
|
| 571 |
+
fn = stable_diffusion_controlnet_depth,
|
| 572 |
inputs = [
|
| 573 |
controlnet_depth_image_file,
|
| 574 |
controlnet_depth_model_id,
|
|
|
|
| 581 |
)
|
| 582 |
|
| 583 |
controlnet_scribble_predict.click(
|
| 584 |
+
fn = stable_diffusion_controlnet_scribble,
|
| 585 |
inputs = [
|
| 586 |
controlnet_scribble_image_file,
|
| 587 |
controlnet_scribble_model_id,
|
|
|
|
| 594 |
)
|
| 595 |
|
| 596 |
controlnet_pose_predict.click(
|
| 597 |
+
fn = stable_diffusion_controlnet_pose,
|
| 598 |
inputs = [
|
| 599 |
controlnet_pose_image_file,
|
| 600 |
controlnet_pose_model_id,
|
controlnet/controlnet_canny.py
CHANGED
|
@@ -27,7 +27,7 @@ def controlnet_canny(
|
|
| 27 |
return controlnet, image
|
| 28 |
|
| 29 |
|
| 30 |
-
def
|
| 31 |
stable_model_path:str,
|
| 32 |
image_path:str,
|
| 33 |
prompt:str,
|
|
|
|
| 27 |
return controlnet, image
|
| 28 |
|
| 29 |
|
| 30 |
+
def stable_diffusion_controlnet_canny(
|
| 31 |
stable_model_path:str,
|
| 32 |
image_path:str,
|
| 33 |
prompt:str,
|
controlnet/controlnet_depth.py
CHANGED
|
@@ -24,7 +24,7 @@ def controlnet_depth(image_path:str):
|
|
| 24 |
|
| 25 |
return controlnet, image
|
| 26 |
|
| 27 |
-
def
|
| 28 |
stable_model_path:str,
|
| 29 |
image_path:str,
|
| 30 |
prompt:str,
|
|
|
|
| 24 |
|
| 25 |
return controlnet, image
|
| 26 |
|
| 27 |
+
def stable_diffusion_controlnet_depth(
|
| 28 |
stable_model_path:str,
|
| 29 |
image_path:str,
|
| 30 |
prompt:str,
|
controlnet/controlnet_hed.py
CHANGED
|
@@ -1,12 +1,9 @@
|
|
| 1 |
from diffusers import ( StableDiffusionControlNetPipeline,
|
| 2 |
-
ControlNetModel, UniPCMultistepScheduler
|
| 3 |
-
DDIMScheduler)
|
| 4 |
|
| 5 |
from controlnet_aux import HEDdetector
|
| 6 |
from PIL import Image
|
| 7 |
-
import numpy as np
|
| 8 |
import torch
|
| 9 |
-
import cv2
|
| 10 |
|
| 11 |
|
| 12 |
def controlnet_hed(image_path:str):
|
|
@@ -22,7 +19,7 @@ def controlnet_hed(image_path:str):
|
|
| 22 |
return controlnet, image
|
| 23 |
|
| 24 |
|
| 25 |
-
def
|
| 26 |
stable_model_path:str,
|
| 27 |
image_path:str,
|
| 28 |
prompt:str,
|
|
|
|
| 1 |
from diffusers import ( StableDiffusionControlNetPipeline,
|
| 2 |
+
ControlNetModel, UniPCMultistepScheduler)
|
|
|
|
| 3 |
|
| 4 |
from controlnet_aux import HEDdetector
|
| 5 |
from PIL import Image
|
|
|
|
| 6 |
import torch
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
def controlnet_hed(image_path:str):
|
|
|
|
| 19 |
return controlnet, image
|
| 20 |
|
| 21 |
|
| 22 |
+
def stable_diffusion_controlnet_hed(
|
| 23 |
stable_model_path:str,
|
| 24 |
image_path:str,
|
| 25 |
prompt:str,
|
controlnet/controlnet_mlsd.py
CHANGED
|
@@ -1,12 +1,9 @@
|
|
| 1 |
from diffusers import ( StableDiffusionControlNetPipeline,
|
| 2 |
-
ControlNetModel, UniPCMultistepScheduler
|
| 3 |
-
DDIMScheduler)
|
| 4 |
|
| 5 |
from controlnet_aux import MLSDdetector
|
| 6 |
from PIL import Image
|
| 7 |
-
import numpy as np
|
| 8 |
import torch
|
| 9 |
-
import cv2
|
| 10 |
|
| 11 |
|
| 12 |
def controlnet_mlsd(image_path:str):
|
|
@@ -22,7 +19,7 @@ def controlnet_mlsd(image_path:str):
|
|
| 22 |
|
| 23 |
return controlnet, image
|
| 24 |
|
| 25 |
-
def
|
| 26 |
stable_model_path:str,
|
| 27 |
image_path:str,
|
| 28 |
prompt:str,
|
|
|
|
| 1 |
from diffusers import ( StableDiffusionControlNetPipeline,
|
| 2 |
+
ControlNetModel, UniPCMultistepScheduler)
|
|
|
|
| 3 |
|
| 4 |
from controlnet_aux import MLSDdetector
|
| 5 |
from PIL import Image
|
|
|
|
| 6 |
import torch
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
def controlnet_mlsd(image_path:str):
|
|
|
|
| 19 |
|
| 20 |
return controlnet, image
|
| 21 |
|
| 22 |
+
def stable_diffusion_controlnet_mlsd(
|
| 23 |
stable_model_path:str,
|
| 24 |
image_path:str,
|
| 25 |
prompt:str,
|
controlnet/controlnet_pose.py
CHANGED
|
@@ -20,7 +20,7 @@ def controlnet_pose(image_path:str):
|
|
| 20 |
|
| 21 |
return controlnet, image
|
| 22 |
|
| 23 |
-
def
|
| 24 |
stable_model_path:str,
|
| 25 |
image_path:str,
|
| 26 |
prompt:str,
|
|
|
|
| 20 |
|
| 21 |
return controlnet, image
|
| 22 |
|
| 23 |
+
def stable_diffusion_controlnet_pose(
|
| 24 |
stable_model_path:str,
|
| 25 |
image_path:str,
|
| 26 |
prompt:str,
|
controlnet/controlnet_scribble.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
from diffusers import ( StableDiffusionControlNetPipeline,
|
| 2 |
-
ControlNetModel, UniPCMultistepScheduler
|
| 3 |
-
DDIMScheduler)
|
| 4 |
|
| 5 |
from controlnet_aux import HEDdetector
|
| 6 |
|
|
@@ -20,7 +19,7 @@ def controlnet_scribble(image_path:str):
|
|
| 20 |
|
| 21 |
return controlnet, image
|
| 22 |
|
| 23 |
-
def
|
| 24 |
stable_model_path:str,
|
| 25 |
image_path:str,
|
| 26 |
prompt:str,
|
|
|
|
| 1 |
from diffusers import ( StableDiffusionControlNetPipeline,
|
| 2 |
+
ControlNetModel, UniPCMultistepScheduler)
|
|
|
|
| 3 |
|
| 4 |
from controlnet_aux import HEDdetector
|
| 5 |
|
|
|
|
| 19 |
|
| 20 |
return controlnet, image
|
| 21 |
|
| 22 |
+
def stable_diffusion_controlnet_scribble(
|
| 23 |
stable_model_path:str,
|
| 24 |
image_path:str,
|
| 25 |
prompt:str,
|
controlnet/controlnet_seg.py
CHANGED
|
@@ -78,7 +78,7 @@ def controlnet_mlsd(image_path:str):
|
|
| 78 |
return controlnet, image
|
| 79 |
|
| 80 |
|
| 81 |
-
def
|
| 82 |
stable_model_path:str,
|
| 83 |
image_path:str,
|
| 84 |
prompt:str,
|
|
|
|
| 78 |
return controlnet, image
|
| 79 |
|
| 80 |
|
| 81 |
+
def stable_diffusion_controlnet_seg(
|
| 82 |
stable_model_path:str,
|
| 83 |
image_path:str,
|
| 84 |
prompt:str,
|