Spaces:
Running
Running
yizhangliu
commited on
Commit
•
a0c3f48
1
Parent(s):
cd30a9d
Update app.py
Browse files
app.py
CHANGED
@@ -127,26 +127,25 @@ def model_process(image, mask):
|
|
127 |
# RGB
|
128 |
# origin_image_bytes = input["image"].read()
|
129 |
|
130 |
-
print(f'liuyz_2_here_', type(image), image)
|
131 |
-
|
132 |
-
image_pil = Image.fromarray(
|
133 |
-
mask_pil = Image.fromarray(
|
134 |
print(f'image_pil_ = {type(image_pil)}')
|
135 |
print(f'mask_pil_ = {type(mask_pil)}')
|
136 |
-
mask_pil.save(f'./mask_pil.png')
|
137 |
|
138 |
-
|
139 |
-
image, alpha_channel = load_img(image)
|
140 |
# Origin image shape: (512, 512, 3)
|
141 |
|
142 |
-
|
143 |
original_shape = image.shape
|
144 |
interpolation = cv2.INTER_CUBIC
|
145 |
|
146 |
# form = request.form
|
147 |
print(f'liuyz_3_here_', original_shape, alpha_channel)
|
148 |
|
149 |
-
size_limit =
|
150 |
if size_limit == "Original":
|
151 |
size_limit = max(image.shape)
|
152 |
else:
|
@@ -188,8 +187,8 @@ def model_process(image, mask):
|
|
188 |
# logger.info(f"Resized image shape: {image.shape}")
|
189 |
print(f"Resized image shape: {image.shape} / {image[250][250]}")
|
190 |
|
191 |
-
mask, _ = load_img(mask, gray=True)
|
192 |
-
|
193 |
mask = resize_max_size(mask, size_limit=size_limit, interpolation=interpolation)
|
194 |
print(f"mask image shape: {mask.shape} / {type(mask)} / {mask[250][250]}")
|
195 |
|
|
|
127 |
# RGB
|
128 |
# origin_image_bytes = input["image"].read()
|
129 |
|
130 |
+
print(f'liuyz_2_here_', type(image), image.shape)
|
131 |
+
|
132 |
+
image_pil = Image.fromarray(image)
|
133 |
+
mask_pil = Image.fromarray(mask).convert("L")
|
134 |
print(f'image_pil_ = {type(image_pil)}')
|
135 |
print(f'mask_pil_ = {type(mask_pil)}')
|
136 |
+
mask_pil.save(f'./mask_pil.png')
|
137 |
|
138 |
+
#image, alpha_channel = load_img(image)
|
|
|
139 |
# Origin image shape: (512, 512, 3)
|
140 |
|
141 |
+
alpha_channel = None
|
142 |
original_shape = image.shape
|
143 |
interpolation = cv2.INTER_CUBIC
|
144 |
|
145 |
# form = request.form
|
146 |
print(f'liuyz_3_here_', original_shape, alpha_channel)
|
147 |
|
148 |
+
size_limit = "Original" # image.shape[1] # : Union[int, str] = form.get("sizeLimit", "1080")
|
149 |
if size_limit == "Original":
|
150 |
size_limit = max(image.shape)
|
151 |
else:
|
|
|
187 |
# logger.info(f"Resized image shape: {image.shape}")
|
188 |
print(f"Resized image shape: {image.shape} / {image[250][250]}")
|
189 |
|
190 |
+
# mask, _ = load_img(mask, gray=True)
|
191 |
+
mask = np.array(mask_pil)
|
192 |
mask = resize_max_size(mask, size_limit=size_limit, interpolation=interpolation)
|
193 |
print(f"mask image shape: {mask.shape} / {type(mask)} / {mask[250][250]}")
|
194 |
|