Spaces:
Runtime error
Runtime error
vahidrezanezhad
commited on
Commit
•
24b9734
1
Parent(s):
8c194a0
Update app.py
Browse files
app.py
CHANGED
@@ -29,8 +29,6 @@ def visualize_model_output(prediction, img):
|
|
29 |
|
30 |
output = np.zeros(prediction.shape)
|
31 |
|
32 |
-
print(output.shape,'shape of output')
|
33 |
-
|
34 |
for unq_class in unique_classes:
|
35 |
print(unq_class,'unq_class')
|
36 |
rgb_class_unique = rgb_colors[str(int(unq_class))]
|
@@ -45,13 +43,9 @@ def visualize_model_output(prediction, img):
|
|
45 |
output = output.astype(np.int32)
|
46 |
img = img.astype(np.int32)
|
47 |
|
48 |
-
print(output,'shapes')
|
49 |
-
print(img,'shapes2')
|
50 |
-
|
51 |
|
52 |
|
53 |
added_image = cv2.addWeighted(img,0.5,output,0.1,0)
|
54 |
-
print(added_image)
|
55 |
return added_image
|
56 |
|
57 |
|
@@ -62,8 +56,18 @@ def do_prediction(model_name, img):
|
|
62 |
match model_name:
|
63 |
# numerical output
|
64 |
case "SBB/eynollah-column-classifier":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
-
|
|
|
67 |
return "Found {} columns".format(num_col), None
|
68 |
|
69 |
# bitmap output
|
|
|
29 |
|
30 |
output = np.zeros(prediction.shape)
|
31 |
|
|
|
|
|
32 |
for unq_class in unique_classes:
|
33 |
print(unq_class,'unq_class')
|
34 |
rgb_class_unique = rgb_colors[str(int(unq_class))]
|
|
|
43 |
output = output.astype(np.int32)
|
44 |
img = img.astype(np.int32)
|
45 |
|
|
|
|
|
|
|
46 |
|
47 |
|
48 |
added_image = cv2.addWeighted(img,0.5,output,0.1,0)
|
|
|
49 |
return added_image
|
50 |
|
51 |
|
|
|
56 |
match model_name:
|
57 |
# numerical output
|
58 |
case "SBB/eynollah-column-classifier":
|
59 |
+
|
60 |
+
img_1ch = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
61 |
+
|
62 |
+
img_1ch = img_1ch / 255.0
|
63 |
+
img_1ch = cv2.resize(img_1ch, (448, 448), interpolation=cv2.INTER_NEAREST)
|
64 |
+
img_in = np.zeros((1, img_1ch.shape[0], img_1ch.shape[1], 3))
|
65 |
+
img_in[0, :, :, 0] = img_1ch[:, :]
|
66 |
+
img_in[0, :, :, 1] = img_1ch[:, :]
|
67 |
+
img_in[0, :, :, 2] = img_1ch[:, :]
|
68 |
|
69 |
+
label_p_pred = model.predict(img_in, verbose=0)
|
70 |
+
num_col = np.argmax(label_p_pred[0]) + 1
|
71 |
return "Found {} columns".format(num_col), None
|
72 |
|
73 |
# bitmap output
|