Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the CRF layer with some other segmentation network #46

Open
gursimarsingh opened this issue Oct 7, 2018 · 8 comments
Open

Using the CRF layer with some other segmentation network #46

gursimarsingh opened this issue Oct 7, 2018 · 8 comments

Comments

@gursimarsingh
Copy link

Hi,
I wish to use the CRF layer with my own segmentation network which is an encoder-decoder network with skip connections. If I use the crf layer as the last layer what kind of things I should keep in mind?
The output of my model has number of channels equal to number of classes (2 in my case) and activation is sigmoid. I connect this layer directly with the CRF layer without any modification to CRF parameters like theta_alpha, theta_beta and theta_gamma. The final loss function that I am using is binary cross entropy. Output of the CRF is being directly fed to the loss function. At the time of inference I am taking argmax for getting the labels. But the output label for every pixel is mostly the same.
Can anyone please help me to understand that what are the things that are particular to the FCN output such that the CRF layer works with it?

Also, If you could please share the training script?

@lixingang
Copy link

Hi,
Is this problem solved? I'm in the similar situation.

@gursimarsingh
Copy link
Author

No

@gyheart
Copy link

gyheart commented Dec 4, 2018

No
Is this problem solved? I'm in the similar problem. @gursimarsingh @lixingang

@JadBatmobile
Copy link

i have done this in my own keras network.

@gyheart
Copy link

gyheart commented Apr 17, 2019

i have done this in my own keras network.

Can you share your code? Thanks.

@jovahe
Copy link

jovahe commented Aug 9, 2019

I add the crfrnn layer in my model such as unet as following, but I dose not know whether is right.
def add_crfrnn(base_model, cofig):
img_input = base_model.input
x = base_model.get_layer('final_conv').output
x = CrfRnnLayer(image_dims=(config.img_w, config.img_h),
num_classes=config.nb_classes,
theta_alpha=160.,
theta_beta=3.,
theta_gamma=3.,
num_iterations=10,
name='crfrnn')([x, img_input])

x = Activation(config.activation, name=config.activation)(x)
model=Model(img_input, x)
model.summary()
return model

@falconjhc
Copy link

i have done this in my own keras network.
Hi, in your work, is CRF trained?

@falconjhc
Copy link

I add the crfrnn layer in my model such as unet as following, but I dose not know whether is right.
def add_crfrnn(base_model, cofig):
img_input = base_model.input
x = base_model.get_layer('final_conv').output
x = CrfRnnLayer(image_dims=(config.img_w, config.img_h),
num_classes=config.nb_classes,
theta_alpha=160.,
theta_beta=3.,
theta_gamma=3.,
num_iterations=10,
name='crfrnn')([x, img_input])

x = Activation(config.activation, name=config.activation)(x)
model=Model(img_input, x)
model.summary()
return model

Hi, if it is done in this way, does the CRF be trained?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants