atatakun commited on
Commit
01ad35f
1 Parent(s): 0215d3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -7,6 +7,10 @@ from annotator.util import resize_image, HWC3
7
  DESCRIPTION = '# ControlNet v1.1 Annotators (that runs on cpu only)'
8
  DESCRIPTION += '\n<p>This app generates Control Image for Mochi Diffusion&apos;s ControlNet.</p>'
9
  DESCRIPTION += '\n<p>HEIC image is not converted. Please use PNG or JPG image.</p>'
 
 
 
 
10
 
11
 
12
  model_canny = None
@@ -236,9 +240,8 @@ def inpaint(image, invert):
236
  # alpha = 255 - image["mask"][:, :, 0:1]
237
  alpha = 255 - image["layers"][0][:, :, 3:]
238
  result = np.concatenate([color, alpha], axis=2)
239
- # result = alpha
240
  return [result]
241
- # return [color]
242
 
243
 
244
  def predict(im):
@@ -268,12 +271,12 @@ with block:
268
 
269
  gr.Markdown("<hr>")
270
  with gr.Row():
271
- gr.Markdown("## Inpaint \n<p>Mochi Diffusion v4.1で使えるようになりました")
272
  with gr.Row():
273
  with gr.Column():
274
  input_image = gr.ImageMask(sources="upload", type="numpy", height="auto")
275
- im_preview = gr.Image()
276
- input_image.change(predict, outputs=im_preview, inputs=input_image, show_progress="hidden")
277
  # input_image = gr.ImageEditor(sources="upload", type="numpy", height="auto", layers="False", brush=gr.Brush(colors=["#000000"]))
278
  # input_image = gr.Image(source='upload', type="numpy", tool="sketch", height=512)
279
  # resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
@@ -282,7 +285,7 @@ with block:
282
  # run_button = gr.Button(label="Run")
283
  with gr.Column():
284
  gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
285
- # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")# run_button.click(fn=inpaint, inputs=[input_image, resolution], outputs=[gallery])
286
  run_button.click(fn=inpaint, inputs=[input_image, invert], outputs=[gallery])
287
 
288
  gr.Markdown("<hr>")
 
7
  DESCRIPTION = '# ControlNet v1.1 Annotators (that runs on cpu only)'
8
  DESCRIPTION += '\n<p>This app generates Control Image for Mochi Diffusion&apos;s ControlNet.</p>'
9
  DESCRIPTION += '\n<p>HEIC image is not converted. Please use PNG or JPG image.</p>'
10
+ DESCRIPTION += '\n<p>Gradioのバージョンが上がって変換される画像がWebpになっています。最新のMochiDiffusionでは問題なく使えるようです。</p>'
11
+ DESCRIPTION += '\n<p>Safariは、ドラッグ&ドロップで画像をアップロードすることができませんので、アップロードボタンをご利用ください。</p>'
12
+ #DESCRIPTION += '\n<p>The version of Gradio has been upgraded and the converted images are now Webp. It seems to be usable with the latest MochiDiffusion without any problems.</p>'
13
+ #DESCRIPTION += '\n<p>If you are using Safari, you cannot upload images by drag and drop, so please use the upload button.</p>'
14
 
15
 
16
  model_canny = None
 
240
  # alpha = 255 - image["mask"][:, :, 0:1]
241
  alpha = 255 - image["layers"][0][:, :, 3:]
242
  result = np.concatenate([color, alpha], axis=2)
 
243
  return [result]
244
+
245
 
246
 
247
  def predict(im):
 
271
 
272
  gr.Markdown("<hr>")
273
  with gr.Row():
274
+ gr.Markdown("## Inpaint \n<p>画像はアップロードボタンを押して登録して下さい。(Mochi Diffusion v4.1以降で使えるようになりました。)")
275
  with gr.Row():
276
  with gr.Column():
277
  input_image = gr.ImageMask(sources="upload", type="numpy", height="auto")
278
+ # im_preview = gr.Image()
279
+ # input_image.change(predict, outputs=im_preview, inputs=input_image, show_progress="hidden")
280
  # input_image = gr.ImageEditor(sources="upload", type="numpy", height="auto", layers="False", brush=gr.Brush(colors=["#000000"]))
281
  # input_image = gr.Image(source='upload', type="numpy", tool="sketch", height=512)
282
  # resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
 
285
  # run_button = gr.Button(label="Run")
286
  with gr.Column():
287
  gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
288
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
289
  run_button.click(fn=inpaint, inputs=[input_image, invert], outputs=[gallery])
290
 
291
  gr.Markdown("<hr>")