juglab / n2v

This is the implementation of Noise2Void training.
Other
387 stars 107 forks source link

output is same as input, is it something wrong with input format? #65

Closed Tejuwi closed 3 years ago

Tejuwi commented 4 years ago

I got the result is same as input but noticed the loss error is decaying well. I have used the below script. can you please help me where I am doing wrong?my input image is tiff but gray image.I am using single channle only.

imgs = datagen.load_imgs_from_directory(directory = "data/input.tif", dims='YXC')
print(imgs[0].shape,imgs[1].shape)
imgs[0]=imgs[0][:,:,:, 0:1]
imgs[1]=imgs[1][:,:,:, 0:1]
print(imgs[0].shape)
print(imgs[1].shape)
the input dimensions are 
(1, 1024, 1024, 4) (1, 1024, 1024, 4)
(1, 1024, 1024, 1)
(1, 1024, 1024, 1)

X = datagen.generate_patches_from_list(imgs[:1], shape=(128,128))
Generated patches: (392, 128, 128, 1)

config = N2VConfig(X, unet_kern_size=3, 
                   train_steps_per_epoch=200, train_epochs=100, train_loss='mse', batch_norm=True, 
                   train_batch_size=128, n2v_perc_pix=0.198, n2v_patch_shape=(64, 64), 
                   unet_n_first = 96,
                   n2v_manipulator='uniform_withCP', n2v_neighborhood_radius=3)

###### Prediction######
input_train = imread('data/test_crop_1.tif')
input_train1=input_train[:,:,0:1]
pred_train1 = model.predict(input_train1, axes='YXC')

The result is same as input, is something wrong with the data format both train and test.?

rdemets commented 3 years ago

Hi. I've just started trying N2V and got the same problem.

Did you find any solution by any chance ?

tibuch commented 3 years ago

Hi @YaswinTeja, very sorry about never answering this issue! Somehow it completely slipped my attention. Thank you for bringing it up again @rdemets.

In the posted snipped I can't see the training of the model and also not how the model was loaded after training.

Wild guess: If you use model = N2V(config, basedir='...', name='...') then a new N2V instance is created which is not trained. If you want to load the trained model you have to omit config and load the model like this: model = N2V(None, basedir='...', name='...').

Let me know if this helps.