Commit
·
1e3c695
1
Parent(s):
5a9aacb
Refactor remove_background function in app.py to save images to a temporary file before processing. This change improves compatibility with the dis_remove_background method by ensuring the image is correctly handled as a file path.
Browse files
app.py
CHANGED
@@ -15,6 +15,7 @@ import os
|
|
15 |
import json
|
16 |
import argparse
|
17 |
import requests
|
|
|
18 |
|
19 |
from model import CRM
|
20 |
from inference import generate3d
|
@@ -69,7 +70,10 @@ def remove_background(
|
|
69 |
) -> PIL.Image.Image:
|
70 |
# Ensure the ONNX model exists (download if needed)
|
71 |
ensure_dis_onnx_model()
|
72 |
-
|
|
|
|
|
|
|
73 |
return extracted_img
|
74 |
|
75 |
def do_resize_content(original_image: Image, scale_rate):
|
|
|
15 |
import json
|
16 |
import argparse
|
17 |
import requests
|
18 |
+
import tempfile
|
19 |
|
20 |
from model import CRM
|
21 |
from inference import generate3d
|
|
|
70 |
) -> PIL.Image.Image:
|
71 |
# Ensure the ONNX model exists (download if needed)
|
72 |
ensure_dis_onnx_model()
|
73 |
+
# Save PIL image to a temporary file
|
74 |
+
with tempfile.NamedTemporaryFile(suffix=".png", delete=True) as temp:
|
75 |
+
image.save(temp.name)
|
76 |
+
extracted_img, mask = dis_remove_background(DIS_ONNX_MODEL_PATH, temp.name)
|
77 |
return extracted_img
|
78 |
|
79 |
def do_resize_content(original_image: Image, scale_rate):
|