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

Index error when training on greyscale data #557

Open
andytmcn opened this issue Jan 12, 2023 · 0 comments
Open

Index error when training on greyscale data #557

andytmcn opened this issue Jan 12, 2023 · 0 comments

Comments

@andytmcn
Copy link

I'm training a dataset using greyscale data normalized between 0 and 1 with a shape 1024,256,1. Following the documentation the input is converted to 3 layers using

BACKBONE = 'resnet18'
base_model = sm.Unet(backbone_name=BACKBONE, encoder_weights='imagenet', 
                      classes=1, activation='sigmoid')

inp = Input(shape=(None, None, 1))
l1 = Conv2D(3, (1, 1))(inp) # map N channels data to 3 channels
out = base_model(l1)

model = Model(inp, out, name=base_model.name)

With the Backbone set to resnet, training is successful. However when I try another backbone such as efficientnet I get the following error

    model, history = main(model, train_gen, val_gen, callbacks, epochs = epochs)  # next section explains the use of sys.exit

  File "/.../...py", line 247, in main
    history = model.fit(train_gen, epochs=epochs, validation_data=val_gen,

  File "/.../lib/python3.9/site-packages/keras/utils/traceback_utils.py", line 67, in error_handler
    raise e.with_traceback(filtered_tb) from None

  File "/.../...py", line 97, in __getitem__
    x = self.preprocessing(x)

  File "/.../lib/python3.9/site-packages/segmentation_models/__init__.py", line 43, in wrapper
    return func(*args, **new_kwargs)

  File "/.../lib/python3.9/site-packages/segmentation_models/__init__.py", line 34, in wrapper
    return func(*args, **kwargs)

  File "/.../lib/python3.9/site-packages/classification_models/models_factory.py", line 78, in wrapper
    return func(*args, **new_kwargs)

  File "/.../lib/python3.9/site-packages/classification_models/models/senet.py", line 435, in preprocess_input
    return imagenet_utils.preprocess_input(x, mode='torch', **kwargs)

IndexError: index 1 is out of bounds for axis 3 with size 1
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

1 participant