Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -36,10 +36,14 @@ def segment_buildings(im):
|
|
36 |
# Convert PIL Image to NumPy array
|
37 |
im = np.array(im)
|
38 |
|
|
|
|
|
|
|
|
|
39 |
outputs = predictor(im)
|
40 |
|
41 |
# We can use `Visualizer` to draw the predictions on the image.
|
42 |
-
v = Visualizer(im
|
43 |
out_im = v.draw_instance_predictions(outputs["instances"].to("cpu")).get_image()
|
44 |
|
45 |
# Convert the output image back to PIL Image
|
|
|
36 |
# Convert PIL Image to NumPy array
|
37 |
im = np.array(im)
|
38 |
|
39 |
+
# Ensure that the image has shape H x W x C (height x width x channels)
|
40 |
+
if im.shape[-1] == 4: # If it has 4 channels (RGBA), remove the alpha channel
|
41 |
+
im = im[:, :, :3]
|
42 |
+
|
43 |
outputs = predictor(im)
|
44 |
|
45 |
# We can use `Visualizer` to draw the predictions on the image.
|
46 |
+
v = Visualizer(im, MetadataCatalog.get(cfg.DATASETS.TRAIN[0]), scale=1.2)
|
47 |
out_im = v.draw_instance_predictions(outputs["instances"].to("cpu")).get_image()
|
48 |
|
49 |
# Convert the output image back to PIL Image
|