From c0adecd5d638c107a8ccefd63fb7fc7d30617daa Mon Sep 17 00:00:00 2001 From: milesial Date: Fri, 27 Dec 2019 18:30:23 +0100 Subject: [PATCH] Removed dense_crf (for real) Former-commit-id: eb54ef62c6c893ab9e93d4a8095b75044c2d33a7 --- .gitignore | 1 + requirements.txt | 2 +- utils/crf.py | 26 -------------------------- 3 files changed, 2 insertions(+), 27 deletions(-) delete mode 100644 utils/crf.py diff --git a/.gitignore b/.gitignore index eeeacd2..da7b4f9 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ checkpoints/ *.pth *.jpg SUBMISSION* +venv/ \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index d22f05c..83de139 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ matplotlib -pydensecrf numpy Pillow torch torchvision +tensorboard \ No newline at end of file diff --git a/utils/crf.py b/utils/crf.py deleted file mode 100644 index 5ee718f..0000000 --- a/utils/crf.py +++ /dev/null @@ -1,26 +0,0 @@ -import numpy as np -import pydensecrf.densecrf as dcrf - - -def dense_crf(img, output_probs): - h = output_probs.shape[0] - w = output_probs.shape[1] - - output_probs = np.expand_dims(output_probs, 0) - output_probs = np.append(1 - output_probs, output_probs, axis=0) - - d = dcrf.DenseCRF2D(w, h, 2) - U = -np.log(output_probs) - U = U.reshape((2, -1)) - U = np.ascontiguousarray(U) - img = np.ascontiguousarray(img) - - d.setUnaryEnergy(U) - - d.addPairwiseGaussian(sxy=20, compat=3) - d.addPairwiseBilateral(sxy=30, srgb=20, rgbim=img, compat=10) - - Q = d.inference(5) - Q = np.argmax(np.array(Q), axis=0).reshape((h, w)) - - return Q