-
Notifications
You must be signed in to change notification settings - Fork 25
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
Use the weights available at https://lmb.informatik.uni-freiburg.de/resources/opensource/unet/ for Tensorflow 2 (Keras) #78
Comments
In principle your approach is fine. caffe stores the weights in order (cOut, cIn, y, x) for convolution and (cIn, cOut, y, x) for up-convolution. Probably dimensions must be permuted a little more to work with the corresponding keras layers? I don't know the native dimension order of keras/tensorflow by heart. But this is my first guess of what might cause your strange outputs. What kind of padding do you use? The plugin processes the image in overlapping tiles and uses mirroring to extrapolate data across image boundaries. You probably used zero padding leading to this wide bright border? |
In TensorFlow, I use the Conv2D object with padding='same'. I changed it to 'valid', but it causes some problem now with layer concatenations. In my network, it is done like this:
and I get this error message:
I guess I need to rearrange the whole network in order to adapt to the padding change. |
Ah, OK, you used padding, you're right U-Net uses valid convolutions. The left blob must be cropped to match the spatial shape of the right blob. This is my keras implementation of U-Net:
I think this should make everything clear. It even includes loading the weights. All the best, |
Thank you! I will have a look. |
This is unfortunately not TensorFlow 2, I will have to do some work to adapt it to my environment. |
Hi again!
there is a conflict between the shapes of the layers in Caffe and the shapes expected by TF:
This could maybe be solved by taking the transpose of the arrays, but then there is the issue with the upconv layers:
These are the problems I had already before setting up this issue. Am I missing something? |
Hi everyone!
I am trying to use the Caffe weights available at https://lmb.informatik.uni-freiburg.de/resources/opensource/unet/ for a model implemented in Tensorflow.
To be more specific, I read the 2d_cell_net_v0.modeldef.h5 file in order to get the layer names in the right order:
Then, I loop through the layers available in the 2d_cell_net_v0.caffemodel.h5 file and try to find the corresponding layers in TensorFlow Keras. Doing this, I saw that the shape of the layers were different and I corrected this. In the end, I extract the weights from the Caffe layer and set the Tensorflow layer with them.
The results are not what I expected:
Could anyone help me with this? What am I missing?
The text was updated successfully, but these errors were encountered: