Spaces:
Runtime error
Runtime error
max
commited on
Commit
•
dfa70ec
1
Parent(s):
de4aa1c
moved ui to gradio blocks
Browse files
app.py
CHANGED
@@ -302,45 +302,54 @@ def _outpaint(img, tosize, border, seed, size, model):
|
|
302 |
# %%
|
303 |
|
304 |
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
)
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
Git LFS Details
|