Spaces:
Running
on
Zero
Running
on
Zero
zhiweili
commited on
Commit
•
6345fdb
1
Parent(s):
12c7808
test control net
Browse files- app.py +1 -1
- app_haircolor_inpaint_15.py +6 -11
- app_haircolor_inpaint_adapter_15.py +1 -1
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
from
|
4 |
|
5 |
with gr.Blocks(css="style.css") as demo:
|
6 |
with gr.Tabs():
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
from app_haircolor_inpaint_15 import create_demo as create_demo_haircolor
|
4 |
|
5 |
with gr.Blocks(css="style.css") as demo:
|
6 |
with gr.Tabs():
|
app_haircolor_inpaint_15.py
CHANGED
@@ -24,8 +24,8 @@ from controlnet_aux import (
|
|
24 |
HEDdetector,
|
25 |
)
|
26 |
|
27 |
-
|
28 |
-
BASE_MODEL = "SG161222/Realistic_Vision_V5.1_noVAE"
|
29 |
|
30 |
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
31 |
|
@@ -53,10 +53,6 @@ controlnet = [
|
|
53 |
"lllyasviel/control_v11p_sd15_softedge",
|
54 |
torch_dtype=torch.float16,
|
55 |
),
|
56 |
-
ControlNetModel.from_pretrained(
|
57 |
-
"lllyasviel/control_v11p_sd15_canny",
|
58 |
-
torch_dtype=torch.float16,
|
59 |
-
),
|
60 |
]
|
61 |
|
62 |
basepipeline = StableDiffusionControlNetInpaintPipeline.from_pretrained(
|
@@ -83,16 +79,15 @@ def image_to_image(
|
|
83 |
generate_size: int,
|
84 |
cond_scale1: float = 1.2,
|
85 |
cond_scale2: float = 1.2,
|
86 |
-
cond_scale3: float = 1.2,
|
87 |
):
|
88 |
run_task_time = 0
|
89 |
time_cost_str = ''
|
90 |
run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
|
91 |
-
canny_image = canny_detector(input_image, int(generate_size*1), generate_size)
|
92 |
lineart_image = lineart_detector(input_image, int(generate_size*1), generate_size)
|
93 |
run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
|
94 |
pidiNet_image = pidiNet_detector(input_image, int(generate_size*1), generate_size)
|
95 |
-
control_image = [lineart_image, pidiNet_image
|
96 |
|
97 |
generator = torch.Generator(device=DEVICE).manual_seed(seed)
|
98 |
generated_image = basepipeline(
|
@@ -106,7 +101,7 @@ def image_to_image(
|
|
106 |
width=generate_size,
|
107 |
guidance_scale=guidance_scale,
|
108 |
num_inference_steps=num_steps,
|
109 |
-
controlnet_conditioning_scale=[cond_scale1, cond_scale2
|
110 |
).images[0]
|
111 |
|
112 |
run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
|
@@ -142,7 +137,7 @@ def create_demo() -> gr.Blocks:
|
|
142 |
edit_prompt = gr.Textbox(lines=1, label="Edit Prompt", value=DEFAULT_EDIT_PROMPT)
|
143 |
generate_size = gr.Number(label="Generate Size", value=512)
|
144 |
with gr.Column():
|
145 |
-
num_steps = gr.Slider(minimum=1, maximum=100, value=
|
146 |
guidance_scale = gr.Slider(minimum=0, maximum=30, value=5, step=0.5, label="Guidance Scale")
|
147 |
with gr.Column():
|
148 |
with gr.Accordion("Advanced Options", open=False):
|
|
|
24 |
HEDdetector,
|
25 |
)
|
26 |
|
27 |
+
BASE_MODEL = "stable-diffusion-v1-5/stable-diffusion-v1-5"
|
28 |
+
# BASE_MODEL = "SG161222/Realistic_Vision_V5.1_noVAE"
|
29 |
|
30 |
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
31 |
|
|
|
53 |
"lllyasviel/control_v11p_sd15_softedge",
|
54 |
torch_dtype=torch.float16,
|
55 |
),
|
|
|
|
|
|
|
|
|
56 |
]
|
57 |
|
58 |
basepipeline = StableDiffusionControlNetInpaintPipeline.from_pretrained(
|
|
|
79 |
generate_size: int,
|
80 |
cond_scale1: float = 1.2,
|
81 |
cond_scale2: float = 1.2,
|
|
|
82 |
):
|
83 |
run_task_time = 0
|
84 |
time_cost_str = ''
|
85 |
run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
|
86 |
+
# canny_image = canny_detector(input_image, int(generate_size*1), generate_size)
|
87 |
lineart_image = lineart_detector(input_image, int(generate_size*1), generate_size)
|
88 |
run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
|
89 |
pidiNet_image = pidiNet_detector(input_image, int(generate_size*1), generate_size)
|
90 |
+
control_image = [lineart_image, pidiNet_image]
|
91 |
|
92 |
generator = torch.Generator(device=DEVICE).manual_seed(seed)
|
93 |
generated_image = basepipeline(
|
|
|
101 |
width=generate_size,
|
102 |
guidance_scale=guidance_scale,
|
103 |
num_inference_steps=num_steps,
|
104 |
+
controlnet_conditioning_scale=[cond_scale1, cond_scale2],
|
105 |
).images[0]
|
106 |
|
107 |
run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
|
|
|
137 |
edit_prompt = gr.Textbox(lines=1, label="Edit Prompt", value=DEFAULT_EDIT_PROMPT)
|
138 |
generate_size = gr.Number(label="Generate Size", value=512)
|
139 |
with gr.Column():
|
140 |
+
num_steps = gr.Slider(minimum=1, maximum=100, value=25, step=1, label="Num Steps")
|
141 |
guidance_scale = gr.Slider(minimum=0, maximum=30, value=5, step=0.5, label="Guidance Scale")
|
142 |
with gr.Column():
|
143 |
with gr.Accordion("Advanced Options", open=False):
|
app_haircolor_inpaint_adapter_15.py
CHANGED
@@ -72,7 +72,7 @@ basepipeline = DiffusionPipeline.from_pretrained(
|
|
72 |
custom_pipeline="./pipelines/pipeline_sd_adapter_inpaint.py",
|
73 |
)
|
74 |
|
75 |
-
|
76 |
|
77 |
basepipeline = basepipeline.to(DEVICE)
|
78 |
|
|
|
72 |
custom_pipeline="./pipelines/pipeline_sd_adapter_inpaint.py",
|
73 |
)
|
74 |
|
75 |
+
basepipeline.scheduler = EulerAncestralDiscreteScheduler.from_config(basepipeline.scheduler.config)
|
76 |
|
77 |
basepipeline = basepipeline.to(DEVICE)
|
78 |
|