max commited on
Commit
dfa70ec
1 Parent(s): de4aa1c

moved ui to gradio blocks

Browse files
Files changed (2) hide show
  1. app.py +51 -42
  2. rgba.gif +2 -2
app.py CHANGED
@@ -302,45 +302,54 @@ def _outpaint(img, tosize, border, seed, size, model):
302
  # %%
303
 
304
 
305
- searchimage = gc.Image(shape=(224, 224), label="image",
306
- type='pil', image_mode='RGBA')
307
- to_size = gc.Slider(1, 1920, 512, step=1, label='output size')
308
- border = gc.Slider(
309
- 1, 50, 0, step=1, label='border to crop from the image before outpainting')
310
- seed = gc.Slider(1, 65536, 10, step=1, label='seed')
311
- size = gc.Slider(0, 1, .5, step=0.01,
312
- label='scale of the image before outpainting')
313
-
314
- out = gc.Image(label="primed image with alpha channel",
315
- type='pil', image_mode='RGBA')
316
- outwithoutalpha = gc.Image(
317
- label="primed image without alpha channel", type='pil')
318
- mask = gc.Image(label="outpainting mask", type='pil')
319
-
320
- model = gc.Dropdown(
321
- choices=['places2',
322
- 'places2+laion300k',
323
- 'places2+laion300k+laion300k(opmasked)',
324
- 'places2+laion300k+laion1200k(opmasked)'
325
- ],
326
- value='places2+laion300k+laion1200k(opmasked)',
327
- label='model',
328
- )
329
-
330
-
331
- maturl = 'https://github.com/fenglinglwb/MAT'
332
- gr.Interface(
333
- _outpaint,
334
- [searchimage, to_size, border, seed, size, model],
335
- [outwithoutalpha, out, mask],
336
- title=f"MAT Primer for Stable Diffusion\n\nbased on MAT: Mask-Aware Transformer for Large Hole Image Inpainting\n\n{maturl}",
337
- description=f"""<html>
338
- create a primer for use in stable diffusion outpainting<br>
339
- examples with strength 0.5
340
- <img src='file/op.gif' /> <img src='file/rgba.gif' />
341
- </html>""",
342
- analytics_enabled=False,
343
- allow_flagging='never',
344
-
345
-
346
- ).launch()
 
 
 
 
 
 
 
 
 
 
302
  # %%
303
 
304
 
305
+ with gr.Blocks() as demo:
306
+ maturl = 'https://github.com/fenglinglwb/MAT'
307
+ gr.Markdown(f'''
308
+ # MAT Primer for Stable Diffusion
309
+ ## based on MAT: Mask-Aware Transformer for Large Hole Image Inpainting
310
+ ### create a primer for use in stable diffusion outpainting
311
+ ''')
312
+
313
+ gr.HTML(f'''<a href="{maturl}">{maturl}</a>''')
314
+ with gr.Box():
315
+ with gr.Row():
316
+ gr.Markdown(f"""example with strength 0.5""")
317
+ with gr.Row():
318
+ gr.HTML("<img src='file/op.gif'> ")
319
+ gr.HTML("<img src='file/rgba.gif'>")
320
+ btn = gr.Button("Run", variant="primary")
321
+ with gr.Row():
322
+ with gr.Column():
323
+ searchimage = gc.Image(
324
+ shape=(224, 224), label="image", type='pil', image_mode='RGBA')
325
+ to_size = gc.Slider(1, 1920, 512, step=1, label='output size')
326
+ border = gc.Slider(
327
+ 1, 50, 0, step=1, label='border to crop from the image before outpainting')
328
+ seed = gc.Slider(1, 65536, 10, step=1, label='seed')
329
+ size = gc.Slider(0, 1, .5, step=0.01,
330
+ label='scale of the image before outpainting')
331
+
332
+ model = gc.Dropdown(
333
+ choices=['places2',
334
+ 'places2+laion300k',
335
+ 'places2+laion300k+laion300k(opmasked)',
336
+ 'places2+laion300k+laion1200k(opmasked)'
337
+ ],
338
+ value='places2+laion300k+laion1200k(opmasked)',
339
+ label='model',
340
+ )
341
+ with gr.Column():
342
+ outwithoutalpha = gc.Image(
343
+ label="primed image without alpha channel", type='pil', image_mode='RGBA')
344
+ mask = gc.Image(label="outpainting mask", type='pil')
345
+ out = gc.Image(label="primed image with alpha channel",
346
+ type='pil', image_mode='RGBA')
347
+
348
+ btn.click(
349
+ fn=_outpaint,
350
+ inputs=[searchimage, to_size, border, seed, size, model],
351
+ outputs=[outwithoutalpha, out, mask])
352
+
353
+
354
+ # %% launch
355
+ demo.launch()
rgba.gif CHANGED

Git LFS Details

  • SHA256: 71e657aaa8d67799b2373068a005ae0656b2efee9af4cec1a85d7b573baf77a4
  • Pointer size: 132 Bytes
  • Size of remote file: 7.73 MB

Git LFS Details

  • SHA256: b1ba0e59fcceb1f685e357eac1de305f98a008e37887015290eea5d23d251bc9
  • Pointer size: 133 Bytes
  • Size of remote file: 10.4 MB