Spaces:
Runtime error
Runtime error
Gaurav
commited on
Commit
•
12fce0c
1
Parent(s):
b3c5171
Update app.py
Browse files
app.py
CHANGED
@@ -11,14 +11,30 @@ preprocessor = MaskFormerFeatureExtractor.from_pretrained("facebook/maskformer-s
|
|
11 |
|
12 |
def visualize_instance_seg_mask(mask):
|
13 |
print(mask)
|
|
|
14 |
image = np.zeros((mask.shape[0], mask.shape[1], 3))
|
15 |
labels = np.unique(mask)
|
16 |
print("================unquie labels")
|
17 |
-
|
|
|
|
|
|
|
18 |
label2color = {label: (random.randint(0, 1), random.randint(0, 255), random.randint(0, 255)) for label in labels}
|
19 |
for i in range(image.shape[0]):
|
20 |
for j in range(image.shape[1]):
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
image = image / 255
|
23 |
return image
|
24 |
|
|
|
11 |
|
12 |
def visualize_instance_seg_mask(mask):
|
13 |
print(mask)
|
14 |
+
print(mask.shape)
|
15 |
image = np.zeros((mask.shape[0], mask.shape[1], 3))
|
16 |
labels = np.unique(mask)
|
17 |
print("================unquie labels")
|
18 |
+
wall=[]
|
19 |
+
floor=[]
|
20 |
+
window=[]
|
21 |
+
other=[]
|
22 |
label2color = {label: (random.randint(0, 1), random.randint(0, 255), random.randint(0, 255)) for label in labels}
|
23 |
for i in range(image.shape[0]):
|
24 |
for j in range(image.shape[1]):
|
25 |
+
if mask[i, j]==0:
|
26 |
+
wall.append([i,j])
|
27 |
+
|
28 |
+
elif mask[i, j]==3
|
29 |
+
floor.append([i,j])
|
30 |
+
|
31 |
+
elif mask[i, j]==8
|
32 |
+
window.append([i,j])
|
33 |
+
else:
|
34 |
+
other.append([i,j])
|
35 |
+
|
36 |
+
image[i, j, :] = label2color[mask[i, j]]
|
37 |
+
print({"floor":floor,"window":window,"wall":wall,"other":other})
|
38 |
image = image / 255
|
39 |
return image
|
40 |
|