atatakun commited on
Commit
a95e279
1 Parent(s): f251dc7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -20
app.py CHANGED
@@ -227,11 +227,14 @@ model_inpaint = None
227
 
228
 
229
  def inpaint(image, invert):
230
- color = HWC3(image["image"])
 
231
  if(invert):
232
- alpha = image["mask"][:, :, 0:1]
 
233
  else:
234
- alpha = 255 - image["mask"][:, :, 0:1]
 
235
  result = np.concatenate([color, alpha], axis=2)
236
  return [result]
237
 
@@ -248,7 +251,8 @@ with block:
248
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
249
  run_button = gr.Button(label="Run")
250
  with gr.Column():
251
- gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
 
252
  run_button.click(fn=canny, inputs=[input_image, resolution, low_threshold, high_threshold], outputs=[gallery])
253
 
254
  gr.Markdown("<hr>")
@@ -260,7 +264,8 @@ with block:
260
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
261
  run_button = gr.Button(label="Run")
262
  with gr.Column():
263
- gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
 
264
  run_button.click(fn=hed, inputs=[input_image, resolution], outputs=[gallery])
265
 
266
  gr.Markdown("<hr>")
@@ -272,7 +277,8 @@ with block:
272
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
273
  run_button = gr.Button(label="Run")
274
  with gr.Column():
275
- gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
 
276
  run_button.click(fn=pidi, inputs=[input_image, resolution], outputs=[gallery])
277
 
278
  gr.Markdown("<hr>")
@@ -286,7 +292,8 @@ with block:
286
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=384, step=64)
287
  run_button = gr.Button(label="Run")
288
  with gr.Column():
289
- gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
 
290
  run_button.click(fn=mlsd, inputs=[input_image, resolution, value_threshold, distance_threshold], outputs=[gallery])
291
 
292
  gr.Markdown("<hr>")
@@ -298,7 +305,8 @@ with block:
298
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=384, step=64)
299
  run_button = gr.Button(label="Run")
300
  with gr.Column():
301
- gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
 
302
  run_button.click(fn=midas, inputs=[input_image, resolution], outputs=[gallery])
303
 
304
 
@@ -311,7 +319,8 @@ with block:
311
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
312
  run_button = gr.Button(label="Run")
313
  with gr.Column():
314
- gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
 
315
  run_button.click(fn=zoe, inputs=[input_image, resolution], outputs=[gallery])
316
 
317
  gr.Markdown("<hr>")
@@ -323,7 +332,8 @@ with block:
323
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
324
  run_button = gr.Button(label="Run")
325
  with gr.Column():
326
- gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
 
327
  run_button.click(fn=normalbae, inputs=[input_image, resolution], outputs=[gallery])
328
 
329
  gr.Markdown("<hr>")
@@ -335,7 +345,8 @@ with block:
335
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
336
  run_button = gr.Button(label="Run")
337
  with gr.Column():
338
- gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
 
339
  run_button.click(fn=dwpose, inputs=[input_image, resolution], outputs=[gallery])
340
 
341
  gr.Markdown("<hr>")
@@ -348,7 +359,8 @@ with block:
348
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
349
  run_button = gr.Button(label="Run")
350
  with gr.Column():
351
- gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
 
352
  run_button.click(fn=openpose, inputs=[input_image, resolution, hand_and_face], outputs=[gallery])
353
 
354
  gr.Markdown("<hr>")
@@ -361,7 +373,8 @@ with block:
361
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
362
  run_button = gr.Button(label="Run")
363
  with gr.Column():
364
- gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
 
365
  run_button.click(fn=lineart_anime, inputs=[input_image, resolution, invert], outputs=[gallery])
366
 
367
  gr.Markdown("<hr>")
@@ -375,7 +388,8 @@ with block:
375
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
376
  run_button = gr.Button(label="Run")
377
  with gr.Column():
378
- gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
 
379
  run_button.click(fn=lineart, inputs=[input_image, resolution, coarse, invert], outputs=[gallery])
380
 
381
  gr.Markdown("<hr>")
@@ -383,11 +397,13 @@ with block:
383
  gr.Markdown("## InPaint")
384
  with gr.Row():
385
  with gr.Column():
386
- input_image = gr.Image(source='upload', type="numpy", tool="sketch", height=512)
 
387
  invert = gr.Checkbox(label='Invert Mask', value=False)
388
  run_button = gr.Button(label="Run")
389
  with gr.Column():
390
- gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
 
391
  run_button.click(fn=inpaint, inputs=[input_image, invert], outputs=[gallery])
392
 
393
  # with gr.Row():
@@ -410,7 +426,8 @@ with block:
410
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
411
  run_button = gr.Button(label="Run")
412
  with gr.Column():
413
- gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
 
414
  run_button.click(fn=oneformer_coco, inputs=[input_image, resolution], outputs=[gallery])
415
 
416
  gr.Markdown("<hr>")
@@ -422,7 +439,8 @@ with block:
422
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=640, step=64)
423
  run_button = gr.Button(label="Run")
424
  with gr.Column():
425
- gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
 
426
  run_button.click(fn=oneformer_ade20k, inputs=[input_image, resolution], outputs=[gallery])
427
 
428
  gr.Markdown("<hr>")
@@ -434,7 +452,8 @@ with block:
434
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
435
  run_button = gr.Button(label="Run")
436
  with gr.Column():
437
- gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
 
438
  run_button.click(fn=content_shuffler, inputs=[input_image, resolution], outputs=[gallery])
439
 
440
  gr.Markdown("<hr>")
@@ -446,7 +465,8 @@ with block:
446
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
447
  run_button = gr.Button(label="Run")
448
  with gr.Column():
449
- gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
 
450
  run_button.click(fn=color_shuffler, inputs=[input_image, resolution], outputs=[gallery])
451
 
452
 
 
227
 
228
 
229
  def inpaint(image, invert):
230
+ # color = HWC3(image["image"])
231
+ color = HWC3(image["background"])
232
  if(invert):
233
+ # alpha = image["mask"][:, :, 0:1]
234
+ alpha = image["layers"][0][:, :, 3:]
235
  else:
236
+ # alpha = 255 - image["mask"][:, :, 0:1]
237
+ alpha = 255 - image["layers"][0][:, :, 3:]
238
  result = np.concatenate([color, alpha], axis=2)
239
  return [result]
240
 
 
251
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
252
  run_button = gr.Button(label="Run")
253
  with gr.Column():
254
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
255
+ gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
256
  run_button.click(fn=canny, inputs=[input_image, resolution, low_threshold, high_threshold], outputs=[gallery])
257
 
258
  gr.Markdown("<hr>")
 
264
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
265
  run_button = gr.Button(label="Run")
266
  with gr.Column():
267
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
268
+ gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
269
  run_button.click(fn=hed, inputs=[input_image, resolution], outputs=[gallery])
270
 
271
  gr.Markdown("<hr>")
 
277
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
278
  run_button = gr.Button(label="Run")
279
  with gr.Column():
280
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
281
+ gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
282
  run_button.click(fn=pidi, inputs=[input_image, resolution], outputs=[gallery])
283
 
284
  gr.Markdown("<hr>")
 
292
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=384, step=64)
293
  run_button = gr.Button(label="Run")
294
  with gr.Column():
295
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
296
+ gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
297
  run_button.click(fn=mlsd, inputs=[input_image, resolution, value_threshold, distance_threshold], outputs=[gallery])
298
 
299
  gr.Markdown("<hr>")
 
305
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=384, step=64)
306
  run_button = gr.Button(label="Run")
307
  with gr.Column():
308
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
309
+ gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
310
  run_button.click(fn=midas, inputs=[input_image, resolution], outputs=[gallery])
311
 
312
 
 
319
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
320
  run_button = gr.Button(label="Run")
321
  with gr.Column():
322
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
323
+ gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
324
  run_button.click(fn=zoe, inputs=[input_image, resolution], outputs=[gallery])
325
 
326
  gr.Markdown("<hr>")
 
332
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
333
  run_button = gr.Button(label="Run")
334
  with gr.Column():
335
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
336
+ gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
337
  run_button.click(fn=normalbae, inputs=[input_image, resolution], outputs=[gallery])
338
 
339
  gr.Markdown("<hr>")
 
345
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
346
  run_button = gr.Button(label="Run")
347
  with gr.Column():
348
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
349
+ gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
350
  run_button.click(fn=dwpose, inputs=[input_image, resolution], outputs=[gallery])
351
 
352
  gr.Markdown("<hr>")
 
359
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
360
  run_button = gr.Button(label="Run")
361
  with gr.Column():
362
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
363
+ gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
364
  run_button.click(fn=openpose, inputs=[input_image, resolution, hand_and_face], outputs=[gallery])
365
 
366
  gr.Markdown("<hr>")
 
373
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
374
  run_button = gr.Button(label="Run")
375
  with gr.Column():
376
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
377
+ gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
378
  run_button.click(fn=lineart_anime, inputs=[input_image, resolution, invert], outputs=[gallery])
379
 
380
  gr.Markdown("<hr>")
 
388
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
389
  run_button = gr.Button(label="Run")
390
  with gr.Column():
391
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
392
+ gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
393
  run_button.click(fn=lineart, inputs=[input_image, resolution, coarse, invert], outputs=[gallery])
394
 
395
  gr.Markdown("<hr>")
 
397
  gr.Markdown("## InPaint")
398
  with gr.Row():
399
  with gr.Column():
400
+ # input_image = gr.Image(source='upload', type="numpy", tool="sketch", height=512)
401
+ input_image = gr.ImageMask(sources="upload", type="numpy", height="auto")
402
  invert = gr.Checkbox(label='Invert Mask', value=False)
403
  run_button = gr.Button(label="Run")
404
  with gr.Column():
405
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
406
+ gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
407
  run_button.click(fn=inpaint, inputs=[input_image, invert], outputs=[gallery])
408
 
409
  # with gr.Row():
 
426
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
427
  run_button = gr.Button(label="Run")
428
  with gr.Column():
429
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
430
+ gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
431
  run_button.click(fn=oneformer_coco, inputs=[input_image, resolution], outputs=[gallery])
432
 
433
  gr.Markdown("<hr>")
 
439
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=640, step=64)
440
  run_button = gr.Button(label="Run")
441
  with gr.Column():
442
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
443
+ gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
444
  run_button.click(fn=oneformer_ade20k, inputs=[input_image, resolution], outputs=[gallery])
445
 
446
  gr.Markdown("<hr>")
 
452
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
453
  run_button = gr.Button(label="Run")
454
  with gr.Column():
455
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
456
+ gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
457
  run_button.click(fn=content_shuffler, inputs=[input_image, resolution], outputs=[gallery])
458
 
459
  gr.Markdown("<hr>")
 
465
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
466
  run_button = gr.Button(label="Run")
467
  with gr.Column():
468
+ # gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
469
+ gallery = gr.Gallery(label="Generated images", show_label=False, height="auto")
470
  run_button.click(fn=color_shuffler, inputs=[input_image, resolution], outputs=[gallery])
471
 
472