Removed dense_crf (for real)

Former-commit-id: eb54ef62c6c893ab9e93d4a8095b75044c2d33a7
This commit is contained in:
milesial 2019-12-27 18:30:23 +01:00
parent 012fca4715
commit c0adecd5d6
3 changed files with 2 additions and 27 deletions

1
.gitignore vendored
View file

@ -5,3 +5,4 @@ checkpoints/
*.pth *.pth
*.jpg *.jpg
SUBMISSION* SUBMISSION*
venv/

View file

@ -1,6 +1,6 @@
matplotlib matplotlib
pydensecrf
numpy numpy
Pillow Pillow
torch torch
torchvision torchvision
tensorboard

View file

@ -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