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

Training on images with 4 channels #16

Open
cspearl opened this issue Sep 2, 2021 · 3 comments
Open

Training on images with 4 channels #16

cspearl opened this issue Sep 2, 2021 · 3 comments

Comments

@cspearl
Copy link

cspearl commented Sep 2, 2021

Hi I am trying to train the model on a custom dataset which has images in 4 channels. RGB images and NIR images could you help me out as to how should I read my data and start training where do i need to do changes in the code?

@sainatarajan
Copy link
Owner

Hi, you could change the input channels to 4 instead of 3 in this line. You can save your files as png images as described in the readme. Do note that this repo doesn't work for multiclass segmentation.

I would instead suggest you have a look at this keras repo or this one if you are working on pytorch.

You can get extremely good results if you use either of the above 2 repos.

@cspearl
Copy link
Author

cspearl commented Sep 3, 2021

I am working with binary segmentation (one class and one background) so your repo would work fine I believe?
I have changed the input channels to 4 in unet.py. How should I change data.py if you could please guide me.

@cspearl
Copy link
Author

cspearl commented Sep 29, 2021

I was training with images of one size(512,512,4) and tried to test the model predictions on images of another size(1024,1024,3) but it is giving an error as to saying : I think we can test on images of any size after we have trained the model
Traceback (most recent call last):
File "unet.py", line 167, in
myunet.train()
File "unet.py", line 134, in train
imgs_mask_test = model.predict(imgs_test, batch_size=1, verbose=1)
File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/keras/engine/training.py", line 908, in predict
use_multiprocessing=use_multiprocessing)
File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/keras/engine/training_arrays.py", line 716, in predict
x, check_steps=True, steps_name='steps', steps=steps)
File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/keras/engine/training.py", line 2471, in _standardize_user_data
exception_prefix='input')
File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/keras/engine/training_utils.py", line 572, in standardize_input_data
str(data_shape))
ValueError: Error when checking input: expected input_2 to have shape (512, 512, 4) but got array with shape (1024, 1024, 3)

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

2 participants