From 0edc87b0842e3c8ac6e31faaf482ae8d7614b764 Mon Sep 17 00:00:00 2001 From: Ehsan Montahaei Date: Sat, 7 Mar 2020 13:26:57 +0330 Subject: [PATCH] safer way of reverse CRF result Sometimes the output of do_crf() mix the labels and cause a bug. Finding label from MAP and assigning MAP in a loop is not safe. --- utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils.py b/utils.py index 919d2ab9..19cc5f34 100644 --- a/utils.py +++ b/utils.py @@ -86,9 +86,10 @@ def do_crf(im, mask, zero_unsure=True): Q = d.inference(5) # 5 - num of iterations MAP = np.argmax(Q, axis=0).reshape(image_size) unique_map = np.unique(MAP) + result = np.copy(MAP) for u in unique_map: # get original labels back - np.putmask(MAP, MAP == u, colors[u]) - return MAP + np.putmask(result, MAP == u, colors[u]) + return result # MAP = do_crf(frame, labels.astype('int32'), zero_unsure=False) def get_available_gpus():