Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -237,18 +237,19 @@ def predict_wsi(image):
|
|
| 237 |
@spaces.GPU(duration=120)
|
| 238 |
def segment_image(image):
|
| 239 |
img = image
|
|
|
|
| 240 |
|
| 241 |
# resize if necessary
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
|
|
|
|
|
|
| 249 |
|
| 250 |
-
img = np.asarray(img)
|
| 251 |
-
print(img.shape)
|
| 252 |
if (np.max(img) > 100):
|
| 253 |
img = img / 255.0
|
| 254 |
transform = T.Compose([T.ToTensor()])
|
|
|
|
| 237 |
@spaces.GPU(duration=120)
|
| 238 |
def segment_image(image):
|
| 239 |
img = image
|
| 240 |
+
img = np.asarray(img)
|
| 241 |
|
| 242 |
# resize if necessary
|
| 243 |
+
h, w = img.shape[:2]
|
| 244 |
+
if min(h, w) < min_side:
|
| 245 |
+
scale = min_side / min(h, w)
|
| 246 |
+
new_w, new_h = int(w * scale), int(h * scale)
|
| 247 |
+
# Convert NumPy array to PIL Image
|
| 248 |
+
image = Image.fromarray(img)
|
| 249 |
+
# Resize the image using PIL
|
| 250 |
+
resized_image = image.resize((new_w, new_h), Image.ANTIALIAS)
|
| 251 |
+
img = np.array(resized_image)
|
| 252 |
|
|
|
|
|
|
|
| 253 |
if (np.max(img) > 100):
|
| 254 |
img = img / 255.0
|
| 255 |
transform = T.Compose([T.ToTensor()])
|