Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,20 +40,17 @@ from rembg import remove
|
|
| 40 |
def processRemove(image_file: Image.Image) -> Image.Image:
|
| 41 |
if image_file is None:
|
| 42 |
return None
|
| 43 |
-
|
| 44 |
-
#
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
# Remove background
|
| 52 |
output_data = remove(input_data)
|
| 53 |
-
|
| 54 |
-
#
|
| 55 |
-
|
| 56 |
-
return output_image
|
| 57 |
|
| 58 |
# --- Upscaling ---
|
| 59 |
MAX_SEED = np.iinfo(np.int32).max
|
|
|
|
| 40 |
def processRemove(image_file: Image.Image) -> Image.Image:
|
| 41 |
if image_file is None:
|
| 42 |
return None
|
| 43 |
+
|
| 44 |
+
# Chuyα»n αΊ£nh PIL thΓ nh bytes
|
| 45 |
+
with BytesIO() as buffer:
|
| 46 |
+
image_file.save(buffer, format="PNG")
|
| 47 |
+
input_data = buffer.getvalue()
|
| 48 |
+
|
| 49 |
+
# XΓ³a nα»n
|
|
|
|
|
|
|
| 50 |
output_data = remove(input_data)
|
| 51 |
+
|
| 52 |
+
# TrαΊ£ vα» αΊ£nh PIL mα»i
|
| 53 |
+
return Image.open(BytesIO(output_data)).convert("RGBA")
|
|
|
|
| 54 |
|
| 55 |
# --- Upscaling ---
|
| 56 |
MAX_SEED = np.iinfo(np.int32).max
|