Upload app.py
Browse files
app.py
CHANGED
|
@@ -5,8 +5,7 @@ from annotator.util import resize_image, HWC3
|
|
| 5 |
|
| 6 |
DESCRIPTION = '# ControlNet v1.1 Annotators (that runs on cpu only)'
|
| 7 |
DESCRIPTION += '\n<p>This app generates Control Image for Mochi Diffusion's ControlNet.</p>'
|
| 8 |
-
DESCRIPTION += '\n<p>HEIC image is not converted. Please use PNG or JPG image
|
| 9 |
-
DESCRIPTION += '\n HEICの画像は変換できません。 PNGまたはJPGの画像を使ってください。</p>'
|
| 10 |
|
| 11 |
|
| 12 |
model_canny = None
|
|
@@ -211,6 +210,15 @@ def color_shuffler(img, res):
|
|
| 211 |
result = model_color_shuffler(img)
|
| 212 |
return [result]
|
| 213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
block = gr.Blocks().queue()
|
| 216 |
with block:
|
|
@@ -228,6 +236,18 @@ with block:
|
|
| 228 |
gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
|
| 229 |
run_button.click(fn=canny, inputs=[input_image, resolution, low_threshold, high_threshold], outputs=[gallery])
|
| 230 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
gr.Markdown("<hr>")
|
| 232 |
with gr.Row():
|
| 233 |
gr.Markdown("## HED Edge "SoftEdge"")
|
|
|
|
| 5 |
|
| 6 |
DESCRIPTION = '# ControlNet v1.1 Annotators (that runs on cpu only)'
|
| 7 |
DESCRIPTION += '\n<p>This app generates Control Image for Mochi Diffusion's ControlNet.</p>'
|
| 8 |
+
DESCRIPTION += '\n<p>HEIC image is not converted. Please use PNG or JPG image.</p>'
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
model_canny = None
|
|
|
|
| 210 |
result = model_color_shuffler(img)
|
| 211 |
return [result]
|
| 212 |
|
| 213 |
+
model_inpaint = None
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
def inpaint(img, res):
|
| 217 |
+
image = resize_image(img, res)
|
| 218 |
+
color = HWC3(image["image"])
|
| 219 |
+
alpha = image["mask"][:, :, 0:1]
|
| 220 |
+
result = np.concatenate([color, alpha], axis=2)
|
| 221 |
+
return [result]
|
| 222 |
|
| 223 |
block = gr.Blocks().queue()
|
| 224 |
with block:
|
|
|
|
| 236 |
gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
|
| 237 |
run_button.click(fn=canny, inputs=[input_image, resolution, low_threshold, high_threshold], outputs=[gallery])
|
| 238 |
|
| 239 |
+
gr.Markdown("<hr>")
|
| 240 |
+
with gr.Row():
|
| 241 |
+
gr.Markdown("## Inpaint \n<p>Mochi Diffusionの次バージョンで使えるようになるかもしれないので試作")
|
| 242 |
+
with gr.Row():
|
| 243 |
+
with gr.Column():
|
| 244 |
+
input_image = gr.Image(source='upload', type="numpy", tool="sketch")
|
| 245 |
+
resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
|
| 246 |
+
run_button = gr.Button(label="Run")
|
| 247 |
+
with gr.Column():
|
| 248 |
+
gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
|
| 249 |
+
run_button.click(fn=inpaint, inputs=[input_image, resolution], outputs=[gallery])
|
| 250 |
+
|
| 251 |
gr.Markdown("<hr>")
|
| 252 |
with gr.Row():
|
| 253 |
gr.Markdown("## HED Edge "SoftEdge"")
|