Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from gradio_imageslider import ImageSlider
|
| 3 |
from loadimg import load_img
|
| 4 |
import spaces
|
| 5 |
from transformers import AutoModelForImageSegmentation
|
|
@@ -36,24 +35,20 @@ def fn(image):
|
|
| 36 |
pred_pil = transforms.ToPILImage()(pred)
|
| 37 |
mask = pred_pil.resize(image_size)
|
| 38 |
image.putalpha(mask)
|
| 39 |
-
return
|
| 40 |
|
| 41 |
|
| 42 |
-
slider1 = ImageSlider(label="birefnet", type="pil")
|
| 43 |
-
slider2 = ImageSlider(label="birefnet", type="pil")
|
| 44 |
image = gr.Image(label="Upload an image")
|
| 45 |
text = gr.Textbox(label="Paste an image URL")
|
| 46 |
|
| 47 |
-
|
| 48 |
chameleon = load_img("chameleon.jpg", output_type="pil")
|
| 49 |
|
| 50 |
url = "https://hips.hearstapps.com/hmg-prod/images/gettyimages-1229892983-square.jpg"
|
| 51 |
tab1 = gr.Interface(
|
| 52 |
-
fn, inputs=image, outputs=
|
| 53 |
)
|
| 54 |
|
| 55 |
-
tab2 = gr.Interface(fn, inputs=text, outputs=
|
| 56 |
-
|
| 57 |
|
| 58 |
demo = gr.TabbedInterface(
|
| 59 |
[tab1, tab2], ["image", "text"], title="birefnet for background removal"
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from loadimg import load_img
|
| 3 |
import spaces
|
| 4 |
from transformers import AutoModelForImageSegmentation
|
|
|
|
| 35 |
pred_pil = transforms.ToPILImage()(pred)
|
| 36 |
mask = pred_pil.resize(image_size)
|
| 37 |
image.putalpha(mask)
|
| 38 |
+
return image # Only returning the processed image
|
| 39 |
|
| 40 |
|
|
|
|
|
|
|
| 41 |
image = gr.Image(label="Upload an image")
|
| 42 |
text = gr.Textbox(label="Paste an image URL")
|
| 43 |
|
|
|
|
| 44 |
chameleon = load_img("chameleon.jpg", output_type="pil")
|
| 45 |
|
| 46 |
url = "https://hips.hearstapps.com/hmg-prod/images/gettyimages-1229892983-square.jpg"
|
| 47 |
tab1 = gr.Interface(
|
| 48 |
+
fn, inputs=image, outputs=gr.Image(type="pil"), examples=[chameleon], api_name="image"
|
| 49 |
)
|
| 50 |
|
| 51 |
+
tab2 = gr.Interface(fn, inputs=text, outputs=gr.Image(type="pil"), examples=[url], api_name="text")
|
|
|
|
| 52 |
|
| 53 |
demo = gr.TabbedInterface(
|
| 54 |
[tab1, tab2], ["image", "text"], title="birefnet for background removal"
|