Skip to content

Commit 650b66a

Browse files
coderzbxzhangbenxing
authored andcommitted
加速label转color
1 parent f1ba3e7 commit 650b66a

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

SelfScripts/__init__.py

Whitespace-only changes.

SelfScripts/demo.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,10 @@ def do(self, image_data):
3737
input_image = np.asarray([input_image])
3838
self.net.forward_all(data=input_image)
3939

40-
predict = self.net.blobs['conv6_interp'].data
41-
out_pred = np.resize(predict, (3, input_shape[2], input_shape[3]))
40+
predict = self.net.blobs['conv6_interp'].data[0, :, :, :]
41+
ind = np.argmax(predict, axis=0)
42+
out_pred = np.resize(ind, (3, input_shape[2], input_shape[3]))
4243
out_pred = out_pred.transpose(1, 2, 0).astype(np.uint8)
43-
for j in range(0, 713):
44-
for k in range(0, 713):
45-
x = -1
46-
label = 0
47-
for i in range(0, 19):
48-
if predict[0][i][j][k] > x:
49-
x = predict[0][i][j][k]
50-
label = i
51-
out_pred[j][k][0] = out_pred[j][k][1] = out_pred[j][k][2] = label
5244
out_rgb = np.zeros(out_pred.shape, dtype=np.uint8)
5345

5446
cv2.LUT(out_pred, label_colours, out_rgb)

0 commit comments

Comments
 (0)