Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,7 @@ import cv2
|
|
11 |
import gradio as gr
|
12 |
import os
|
13 |
from PIL import Image
|
|
|
14 |
import numpy as np
|
15 |
import torch
|
16 |
from torch.autograd import Variable
|
@@ -138,11 +139,13 @@ def inference(image):
|
|
138 |
|
139 |
pil_mask = Image.fromarray(mask).convert('L')
|
140 |
im_rgb = Image.open(image).convert("RGB")
|
|
|
|
|
141 |
|
142 |
im_rgba = im_rgb.copy()
|
143 |
im_rgba.putalpha(pil_mask)
|
144 |
|
145 |
-
return im_rgba
|
146 |
|
147 |
|
148 |
title = "Bg remover for sarvm catalog"
|
@@ -152,7 +155,7 @@ article = "<div><center><img src='https://visitor-badge.glitch.me/badge?page_id=
|
|
152 |
interface = gr.Interface(
|
153 |
fn=inference,
|
154 |
inputs=gr.Image(type='filepath'),
|
155 |
-
outputs="image",
|
156 |
title=title,
|
157 |
description=description,
|
158 |
article=article,
|
|
|
11 |
import gradio as gr
|
12 |
import os
|
13 |
from PIL import Image
|
14 |
+
from rembg import remove
|
15 |
import numpy as np
|
16 |
import torch
|
17 |
from torch.autograd import Variable
|
|
|
139 |
|
140 |
pil_mask = Image.fromarray(mask).convert('L')
|
141 |
im_rgb = Image.open(image).convert("RGB")
|
142 |
+
imrgba1 = img_rgb.copy()
|
143 |
+
imrgba2 = remove(imrgba1,210)
|
144 |
|
145 |
im_rgba = im_rgb.copy()
|
146 |
im_rgba.putalpha(pil_mask)
|
147 |
|
148 |
+
return im_rgba, imrgba2
|
149 |
|
150 |
|
151 |
title = "Bg remover for sarvm catalog"
|
|
|
155 |
interface = gr.Interface(
|
156 |
fn=inference,
|
157 |
inputs=gr.Image(type='filepath'),
|
158 |
+
outputs=["image","image"]
|
159 |
title=title,
|
160 |
description=description,
|
161 |
article=article,
|