Keras Implementation of Unet with EfficientNet as encoder
- Unet with EfficientNet encoder
- EfficientNet-B0
- EfficientNet-B1
- EfficientNet-B2
- EfficientNet-B3
- EfficientNet-B4
- EfficientNet-B5
- EfficientNet-B6
- EfficientNet-B7
tensorflow >= 1.13.1
Keras >= 2.2.4
(It will automatically be installed when you installefficientunet
)
When I built this, tensorflow 1.13.1
and keras 2.2.4
are the latest. There was no TF2.0
. All the functions and the so-called "best practices" I used in this project may be obsolete. Anyway, this library still works. But please keep in mind, this is built before the advent of TF2.0
.
Install efficientunet
:
pip install efficientunet
from efficientunet import *
model = get_efficient_unet_b5((224, 224, 3), pretrained=True, block_type='transpose', concat_input=True)
model.summary()
-
This library assumes
channels_last
! -
You cannot specify
None
forinput_shape
, since theinput_shape
is heavily used in the code for inferring the architecture. (The EfficientUnets are constructed dynamically) -
Since you cannot use
None
forinput_shape
, the image size for training process and for inference process have to be the same.
If you do need to use a different image size for inference, a feasible solution is:- Save the weights of your well-trained model
- Create a new model with the desired input shape
- Load the weights of your well-trained model into this newly created model
-
Due to some rounding problem in the decoder path (not a bug, this is a feature 😏), the input shape should be divisible by 32.
e.g. 224x224 is a suitable size for input images, but 225x225 is not.
- If you are unable to load the model from the saved HDF5 file, please refer to this issue.
- Especially this comment can be used as a workaround.