Upload app.py
Browse files
app.py
CHANGED
@@ -214,10 +214,13 @@ def color_shuffler(img, res):
|
|
214 |
model_inpaint = None
|
215 |
|
216 |
|
217 |
-
def inpaint(image):
|
218 |
# image = resize_image(img, res)
|
219 |
color = HWC3(image["image"])
|
220 |
-
|
|
|
|
|
|
|
221 |
result = np.concatenate([color, alpha], axis=2)
|
222 |
return [result]
|
223 |
|
@@ -239,16 +242,17 @@ with block:
|
|
239 |
|
240 |
gr.Markdown("<hr>")
|
241 |
with gr.Row():
|
242 |
-
gr.Markdown("## Inpaint \n<p>Mochi Diffusion
|
243 |
with gr.Row():
|
244 |
with gr.Column():
|
245 |
input_image = gr.Image(source='upload', type="numpy", tool="sketch", height=512)
|
246 |
# resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
|
|
|
247 |
run_button = gr.Button(label="Run")
|
248 |
with gr.Column():
|
249 |
gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
|
250 |
# run_button.click(fn=inpaint, inputs=[input_image, resolution], outputs=[gallery])
|
251 |
-
run_button.click(fn=inpaint, inputs=[input_image], outputs=[gallery])
|
252 |
|
253 |
gr.Markdown("<hr>")
|
254 |
with gr.Row():
|
|
|
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 |
|
|
|
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='Mask Invert', 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():
|