Spaces:
Sleeping
Sleeping
Commit
·
85eb890
1
Parent(s):
e044413
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
|
| 2 |
import time
|
| 3 |
|
| 4 |
|
|
@@ -7,25 +7,40 @@ def sleep(im):
|
|
| 7 |
return [im["background"], im["layers"][0], im["layers"][1], im["composite"]]
|
| 8 |
|
| 9 |
|
|
|
|
| 10 |
def predict(im):
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
with gr.Row():
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
|
| 30 |
if __name__ == "__main__":
|
| 31 |
demo.launch()
|
|
|
|
|
|
| 1 |
+
mport gradio as gr
|
| 2 |
import time
|
| 3 |
|
| 4 |
|
|
|
|
| 7 |
return [im["background"], im["layers"][0], im["layers"][1], im["composite"]]
|
| 8 |
|
| 9 |
|
| 10 |
+
support_im_masks = [None for _ in range(1000)]
|
| 11 |
def predict(im):
|
| 12 |
+
for i in range(len(support_im_masks)):
|
| 13 |
+
if support_im_masks[i] is None:
|
| 14 |
+
break
|
| 15 |
+
support_im_mask = support_im_masks[i]
|
| 16 |
+
gr.Button(support_im_mask)
|
| 17 |
+
pass
|
| 18 |
|
| 19 |
with gr.Blocks() as demo:
|
| 20 |
+
b = gr.Button("Add Textbox")
|
| 21 |
+
b2 = gr.Button("Generate Masks")
|
| 22 |
+
b2.click(predict)
|
| 23 |
+
print('hi')
|
| 24 |
+
|
| 25 |
+
num = gr.State(0)
|
| 26 |
+
|
| 27 |
+
b.click(lambda x:x+1, num, num)
|
| 28 |
+
|
| 29 |
with gr.Row():
|
| 30 |
+
query_im = gr.Image(label='query image')
|
| 31 |
+
|
| 32 |
+
@gr.render(inputs=num)
|
| 33 |
+
def show_support_imgs(n):
|
| 34 |
+
with gr.Column():
|
| 35 |
+
for i in range(n):
|
| 36 |
+
support_im = gr.ImageEditor(
|
| 37 |
+
label="support image {}".format(i),
|
| 38 |
+
type="numpy",
|
| 39 |
+
crop_size="1:1",
|
| 40 |
+
)
|
| 41 |
+
support_im_masks[i] = support_im
|
| 42 |
+
|
| 43 |
|
| 44 |
if __name__ == "__main__":
|
| 45 |
demo.launch()
|
| 46 |
+
|