Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,15 +16,15 @@ def remove_background(image):
|
|
| 16 |
else:
|
| 17 |
raise TypeError("Unsupported image type")
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
|
| 25 |
return output
|
| 26 |
|
| 27 |
-
#
|
| 28 |
iface = gr.Interface(
|
| 29 |
fn=remove_background,
|
| 30 |
inputs=gr.Image(label="Upload Image"),
|
|
|
|
| 16 |
else:
|
| 17 |
raise TypeError("Unsupported image type")
|
| 18 |
|
| 19 |
+
# 确保输出图片的背景是透明的,并以PNG格式保存
|
| 20 |
+
output_bytes = io.BytesIO()
|
| 21 |
+
output.save(output_bytes, format="PNG")
|
| 22 |
+
output_bytes.seek(0)
|
| 23 |
+
output = Image.open(output_bytes)
|
| 24 |
|
| 25 |
return output
|
| 26 |
|
| 27 |
+
# 界面设置
|
| 28 |
iface = gr.Interface(
|
| 29 |
fn=remove_background,
|
| 30 |
inputs=gr.Image(label="Upload Image"),
|