Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,8 +4,13 @@ from PIL import Image
|
|
| 4 |
import io
|
| 5 |
|
| 6 |
def remove_bg(input_image):
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
demo = gr.Interface(fn=remove_bg, inputs=gr.Image(type="pil"), outputs="image")
|
| 11 |
demo.launch()
|
|
|
|
| 4 |
import io
|
| 5 |
|
| 6 |
def remove_bg(input_image):
|
| 7 |
+
try:
|
| 8 |
+
if input_image is None:
|
| 9 |
+
return "Error: No image received"
|
| 10 |
+
output = remove(input_image)
|
| 11 |
+
return Image.open(io.BytesIO(output))
|
| 12 |
+
except Exception as e:
|
| 13 |
+
return f"Error: {str(e)}"
|
| 14 |
|
| 15 |
demo = gr.Interface(fn=remove_bg, inputs=gr.Image(type="pil"), outputs="image")
|
| 16 |
demo.launch()
|