Thank you for sharing your work.
I add dense3dCrf to the output of a 3d CNN segmentation model as below and receive an error.
What do I miss in crf configuration?
Thanks!
import dense_crf
import nibabel
import numpy as np
import nibabel as nib
# I is image
# P is cnn output
I = np.load('test_X.npy')
P = np.load('test_y_hat.npy')
# somehow, crf requires I to be int8 and P to be float32
I = I * 255
I[I < 0] = 0
I[I > 255] = 255
# try to expand dimension
I = np.expand_dims(I, axis=-1)
P = np.expand_dims(P, axis=-1)
I = np.asarray(I, np.uint8)
P = np.asarray(P, np.float32)
# sanity check
print('type I: {}, shape I: {}, dtype: {}'.format(type(I), I.shape, I.dtype))
print('type P: {}, shape P: {}, dtype: {}'.format(type(P), P.shape, P.dtype))
dense_crf_param = {}
dense_crf_param['MaxIterations'] = 2.0
dense_crf_param['PosRStd'] = 3.0
dense_crf_param['PosCStd'] = 3.0
dense_crf_param['PosZStd'] = 3.0
dense_crf_param['PosW'] = 1.0
dense_crf_param['ModalityNum'] = 1
dense_crf_param['BilateralRStd'] = 5.0
dense_crf_param['BilateralCStd'] = 5.0
dense_crf_param['BilateralZStd'] = 5.0
dense_crf_param['BilateralW'] = 3.0
dense_crf_param['BilateralModsStds'] = 3.0
print('crf config ok')
# inference
y_hat_crf = dense_crf.dense_crf(I, P, dense_crf_param)
input data channel 1 and BilateralModsStds size 0 do not match
Traceback (most recent call last):
File "\<stdin>", line 47, in
SystemError: error return without exception set
Hello @dspdavinci
I want to apply 3dcrf to a 3D matrix of segmentation masks
I think what you've done it's pretty similiar to what I want
Did you have results? Could you use it?
Hello Kamnitsask,
Thank you for sharing your work. I add dense3dCrf to the output of a 3d CNN segmentation model as below and receive an error. What do I miss in crf configuration?
Thanks!
Output