Update app.py
Browse files
app.py
CHANGED
|
@@ -27,8 +27,10 @@ def remove_background(image):
|
|
| 27 |
img_bytes.seek(0)
|
| 28 |
|
| 29 |
# Step 1: Remove background using the Gradio API
|
| 30 |
-
result_url = background_removal_client.predict(
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
# Step 2: Download the image returned by the API
|
| 33 |
response = requests.get(result_url)
|
| 34 |
foreground = Image.open(BytesIO(response.content)).convert("RGBA")
|
|
|
|
| 27 |
img_bytes.seek(0)
|
| 28 |
|
| 29 |
# Step 1: Remove background using the Gradio API
|
| 30 |
+
result_url = background_removal_client.predict(
|
| 31 |
+
f=img_bytes.getvalue(), # Use getvalue() to get bytes
|
| 32 |
+
api_name="/png"
|
| 33 |
+
)
|
| 34 |
# Step 2: Download the image returned by the API
|
| 35 |
response = requests.get(result_url)
|
| 36 |
foreground = Image.open(BytesIO(response.content)).convert("RGBA")
|