qubvel / segmentation_models

Segmentation models with pretrained backbones. Keras and TensorFlow Keras.
MIT License
4.67k stars 1.03k forks source link

Question: Unet (resnet) filter size. #522

Open stianteien opened 2 years ago

stianteien commented 2 years ago

Is there an easy way to select the sizes of the filters in the Unet-resnet? It looks like it starts at 64, and then goes through the U with the lowest at 512. Can I change this?

It is ok if the data is low spectral resolution (like RGB), but I think I am losing some information because I have over 300 spectral channels as input.

I tried encoder_features, but that was not so user-friendly.

edit: Question 2: can I change the depth aswell?

attiladoor commented 1 year ago

Hej, I am looking the same thing, which unfortunately i cannot answer yet, but from the documentation, it looks like, encoder_features is for creating skip connections between the encoder and the decoder: https://github.com/qubvel/segmentation_models/blob/94f624b7029deb463c859efbd92fa26f512b52b8/segmentation_models/models/unet.py#L190

The depth, you can change on decoder size for sure. This is how i do it:

model = sm.Unet( "resnet18", input_shape=(img_size[0], img_size[1], 4), classes=num_classes, activation="sigmoid", encoder_weights=None, decoder_filters=(64, 32, 16, 8), ) To create a quarter resolution output. Note that the "decoder_filters" is trimmed.