Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import cv2
|
| 3 |
-
import numpy as np
|
| 4 |
|
| 5 |
from annotator.util import resize_image, HWC3
|
| 6 |
|
|
@@ -211,18 +210,6 @@ def color_shuffler(img, res):
|
|
| 211 |
result = model_color_shuffler(img)
|
| 212 |
return [result]
|
| 213 |
|
| 214 |
-
model_inpaint = None
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
def inpaint(image, invert):
|
| 218 |
-
# image = resize_image(img, res)
|
| 219 |
-
color = HWC3(image["image"])
|
| 220 |
-
if(invert):
|
| 221 |
-
alpha = image["mask"][:, :, 0:1]
|
| 222 |
-
else:
|
| 223 |
-
alpha = 255 - image["mask"][:, :, 0:1]
|
| 224 |
-
result = np.concatenate([color, alpha], axis=2)
|
| 225 |
-
return [result]
|
| 226 |
|
| 227 |
block = gr.Blocks().queue()
|
| 228 |
with block:
|
|
@@ -240,20 +227,6 @@ with block:
|
|
| 240 |
gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
|
| 241 |
run_button.click(fn=canny, inputs=[input_image, resolution, low_threshold, high_threshold], outputs=[gallery])
|
| 242 |
|
| 243 |
-
gr.Markdown("<hr>")
|
| 244 |
-
with gr.Row():
|
| 245 |
-
gr.Markdown("## Inpaint \n<p>Mochi Diffusionの次バージョンで使えるようになるかもしれないので試作中")
|
| 246 |
-
with gr.Row():
|
| 247 |
-
with gr.Column():
|
| 248 |
-
input_image = gr.Image(source='upload', type="numpy", tool="sketch", height=512)
|
| 249 |
-
# resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
|
| 250 |
-
invert = gr.Checkbox(label='Invert Mask', value=False)
|
| 251 |
-
run_button = gr.Button(label="Run")
|
| 252 |
-
with gr.Column():
|
| 253 |
-
gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
|
| 254 |
-
# run_button.click(fn=inpaint, inputs=[input_image, resolution], outputs=[gallery])
|
| 255 |
-
run_button.click(fn=inpaint, inputs=[input_image, invert], outputs=[gallery])
|
| 256 |
-
|
| 257 |
gr.Markdown("<hr>")
|
| 258 |
with gr.Row():
|
| 259 |
gr.Markdown("## HED Edge "SoftEdge"")
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import cv2
|
|
|
|
| 3 |
|
| 4 |
from annotator.util import resize_image, HWC3
|
| 5 |
|
|
|
|
| 210 |
result = model_color_shuffler(img)
|
| 211 |
return [result]
|
| 212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
block = gr.Blocks().queue()
|
| 215 |
with block:
|
|
|
|
| 227 |
gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
|
| 228 |
run_button.click(fn=canny, inputs=[input_image, resolution, low_threshold, high_threshold], outputs=[gallery])
|
| 229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
gr.Markdown("<hr>")
|
| 231 |
with gr.Row():
|
| 232 |
gr.Markdown("## HED Edge "SoftEdge"")
|