Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -199,7 +199,6 @@ def generate_colored_image(labels):
|
|
| 199 |
for i in range(0,w):
|
| 200 |
for j in range(0,h):
|
| 201 |
new_mk[i][j] = colors[labels[i][j]]
|
| 202 |
-
# new_mk = new_mk / 255.0
|
| 203 |
new_mk = new_mk.astype(np.uint8)
|
| 204 |
return Image.fromarray(new_mk)
|
| 205 |
|
|
@@ -270,7 +269,7 @@ def segment_image(image):
|
|
| 270 |
|
| 271 |
return image, legend, stats, superimposed_image
|
| 272 |
|
| 273 |
-
def superimpose_images(image1,
|
| 274 |
|
| 275 |
if image1.dtype != np.uint8:
|
| 276 |
image1 = (image1 * 255).astype(np.uint8) if image1.max() <= 1 else image1.astype(np.uint8)
|
|
@@ -280,10 +279,13 @@ def superimpose_images(image1, image2, alpha=0.2):
|
|
| 280 |
# Resize image1 to match image2's size
|
| 281 |
image1 = image1.resize(image2.size)
|
| 282 |
|
| 283 |
-
|
| 284 |
-
|
| 285 |
|
| 286 |
-
|
|
|
|
|
|
|
|
|
|
| 287 |
|
| 288 |
|
| 289 |
model_path = os.path.join(model_dir, 'spaderesnet.pt')
|
|
|
|
| 199 |
for i in range(0,w):
|
| 200 |
for j in range(0,h):
|
| 201 |
new_mk[i][j] = colors[labels[i][j]]
|
|
|
|
| 202 |
new_mk = new_mk.astype(np.uint8)
|
| 203 |
return Image.fromarray(new_mk)
|
| 204 |
|
|
|
|
| 269 |
|
| 270 |
return image, legend, stats, superimposed_image
|
| 271 |
|
| 272 |
+
def superimpose_images(image1, image):
|
| 273 |
|
| 274 |
if image1.dtype != np.uint8:
|
| 275 |
image1 = (image1 * 255).astype(np.uint8) if image1.max() <= 1 else image1.astype(np.uint8)
|
|
|
|
| 279 |
# Resize image1 to match image2's size
|
| 280 |
image1 = image1.resize(image2.size)
|
| 281 |
|
| 282 |
+
image_np = np.array(image1)
|
| 283 |
+
heatmap_np = np.array(image2)
|
| 284 |
|
| 285 |
+
superimposed_np = cv2.addWeighted(heatmap_np, 0.2, image_np, 1, 0)
|
| 286 |
+
superimposed_pil = Image.fromarray(superimposed_np)
|
| 287 |
+
|
| 288 |
+
return superimposed_pil
|
| 289 |
|
| 290 |
|
| 291 |
model_path = os.path.join(model_dir, 'spaderesnet.pt')
|