add sam2 tab
Browse files
app.py
CHANGED
|
@@ -120,6 +120,10 @@ def rmbg(image=None, url=None):
|
|
| 120 |
return image
|
| 121 |
|
| 122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
@spaces.GPU
|
| 124 |
def main(*args):
|
| 125 |
api_num = args[0]
|
|
@@ -130,12 +134,14 @@ def main(*args):
|
|
| 130 |
return outpaint(*args)
|
| 131 |
elif api_num == 3:
|
| 132 |
return inpaint(*args)
|
|
|
|
|
|
|
| 133 |
|
| 134 |
|
| 135 |
rmbg_tab = gr.Interface(
|
| 136 |
fn=main,
|
| 137 |
inputs=[
|
| 138 |
-
gr.Number(1,
|
| 139 |
"image",
|
| 140 |
gr.Text("", label="url"),
|
| 141 |
],
|
|
@@ -149,7 +155,7 @@ rmbg_tab = gr.Interface(
|
|
| 149 |
outpaint_tab = gr.Interface(
|
| 150 |
fn=main,
|
| 151 |
inputs=[
|
| 152 |
-
gr.Number(2,
|
| 153 |
gr.Image(label="image", type="pil"),
|
| 154 |
gr.Number(label="padding top"),
|
| 155 |
gr.Number(label="padding bottom"),
|
|
@@ -169,7 +175,7 @@ outpaint_tab = gr.Interface(
|
|
| 169 |
inpaint_tab = gr.Interface(
|
| 170 |
fn=main,
|
| 171 |
inputs=[
|
| 172 |
-
gr.Number(3,
|
| 173 |
gr.Image(label="image", type="pil"),
|
| 174 |
gr.Image(label="mask", type="pil"),
|
| 175 |
gr.Text(label="prompt"),
|
|
@@ -183,9 +189,20 @@ inpaint_tab = gr.Interface(
|
|
| 183 |
description="it is recommended that you use https://github.com/la-voliere/react-mask-editor when creating an image mask in JS and then inverse it before sending it to this space",
|
| 184 |
)
|
| 185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
demo = gr.TabbedInterface(
|
| 187 |
-
[rmbg_tab, outpaint_tab, inpaint_tab],
|
| 188 |
-
["remove background", "outpainting", "inpainting"],
|
| 189 |
title="Utilities that require GPU",
|
| 190 |
)
|
| 191 |
|
|
|
|
| 120 |
return image
|
| 121 |
|
| 122 |
|
| 123 |
+
def mask_generation(image=None, json=None):
|
| 124 |
+
return None
|
| 125 |
+
|
| 126 |
+
|
| 127 |
@spaces.GPU
|
| 128 |
def main(*args):
|
| 129 |
api_num = args[0]
|
|
|
|
| 134 |
return outpaint(*args)
|
| 135 |
elif api_num == 3:
|
| 136 |
return inpaint(*args)
|
| 137 |
+
elif api_num == 4:
|
| 138 |
+
return mask_generation(*args)
|
| 139 |
|
| 140 |
|
| 141 |
rmbg_tab = gr.Interface(
|
| 142 |
fn=main,
|
| 143 |
inputs=[
|
| 144 |
+
gr.Number(1, interactive=False),
|
| 145 |
"image",
|
| 146 |
gr.Text("", label="url"),
|
| 147 |
],
|
|
|
|
| 155 |
outpaint_tab = gr.Interface(
|
| 156 |
fn=main,
|
| 157 |
inputs=[
|
| 158 |
+
gr.Number(2, interactive=False),
|
| 159 |
gr.Image(label="image", type="pil"),
|
| 160 |
gr.Number(label="padding top"),
|
| 161 |
gr.Number(label="padding bottom"),
|
|
|
|
| 175 |
inpaint_tab = gr.Interface(
|
| 176 |
fn=main,
|
| 177 |
inputs=[
|
| 178 |
+
gr.Number(3, interactive=False),
|
| 179 |
gr.Image(label="image", type="pil"),
|
| 180 |
gr.Image(label="mask", type="pil"),
|
| 181 |
gr.Text(label="prompt"),
|
|
|
|
| 189 |
description="it is recommended that you use https://github.com/la-voliere/react-mask-editor when creating an image mask in JS and then inverse it before sending it to this space",
|
| 190 |
)
|
| 191 |
|
| 192 |
+
|
| 193 |
+
sam2_tab = gr.Interface(
|
| 194 |
+
main,
|
| 195 |
+
inputs=[
|
| 196 |
+
gr.Number(4, interactive=False),
|
| 197 |
+
gr.Image("image", type="pil"),
|
| 198 |
+
gr.JSON(),
|
| 199 |
+
],
|
| 200 |
+
outputs=["image"],
|
| 201 |
+
)
|
| 202 |
+
|
| 203 |
demo = gr.TabbedInterface(
|
| 204 |
+
[rmbg_tab, outpaint_tab, inpaint_tab, sam2_tab],
|
| 205 |
+
["remove background", "outpainting", "inpainting", "sam2"],
|
| 206 |
title="Utilities that require GPU",
|
| 207 |
)
|
| 208 |
|