GAN-MRI icon indicating copy to clipboard operation
GAN-MRI copied to clipboard

some error about running code

Open fdcqqqq opened this issue 4 years ago • 18 comments

Hi @simontomaskarlsson , I am a graduate student of medical image processing. I encountered two mistakes when debugging your code. I don't know how to solve them. as follows: 1)File "CycleGAN.py", line 744, in get_lr_linear_decay_rate decay_D = self.learning_rate_D / denominator_D ZeroDivisionError: float division by zero

2)UnboundLocalError: local variable 'real_images_A' referenced before assignment

I don't know if it's because of my own data set. My data is made from Brats2018 data set in .tif format. I am Looking forward to your reply. Thankyou~

fdcqqqq avatar Sep 11 '19 13:09 fdcqqqq

Hi @fdcqqqq,

I believe both errors come från the same problem. Since our reasearch never handled .tif images the load_data.py does not handle them. To fix this, modify on row 50 by changing:

if image_name[-1].lower() == 'g':

to

if image_name[-1].lower() == 'f':

I have't tried this but I think the model should handle .tif as long as they are loaded correctly.

Regards, Simon

simontomaskarlsson avatar Sep 12 '19 04:09 simontomaskarlsson

Hi @simontomaskarlsson , Thank you for your reply. I have solved this problem. In addition, I have some questions. Some of the sampled pictures I trained were black, and the effect was very bad. It was hard to see. So, I want to ask you about your data format, such as how many bits, the size of the picture and the number of channels. Looking forward to your reply.

fdcqqqq avatar Sep 17 '19 03:09 fdcqqqq

Hi @fdcqqqq, In our research we used 16 bit .png images of the size 304x256 pixels with one channel.

simontomaskarlsson avatar Sep 17 '19 06:09 simontomaskarlsson

ok,thanks.

fdcqqqq avatar Sep 17 '19 07:09 fdcqqqq

Hi @simontomaskarlsson , The image I transformed is all black, so I used my original image, its bit depth is 32, and then the resolution is 240*240. After being put into the network, the sampled image trained is black and blurred. The first image in the sampled image should be obvious, but the sampled image I got is also blurred.I don't know why, so I'll ask you again. Looking forward to your recovery.

fdcqqqq avatar Sep 17 '19 09:09 fdcqqqq

It could perhaps be a normalization error. Look at the values in the resulting image and try to draw conclusions. Maybe multiply the whole image with 255?

simontomaskarlsson avatar Sep 17 '19 09:09 simontomaskarlsson

Hi @simon, I don't quite understand what you mean by multiplying the whole image by 255, but I think your image has a normalized operation 127.5-1 in the program, but my image is different from your image number, so I think there's something wrong with it.

fdcqqqq avatar Sep 17 '19 12:09 fdcqqqq

I simply meant to scale and translate your output to the expected values the image viewer you are using wants. I guess between 0-255 are common so perhaps try that.

simontomaskarlsson avatar Sep 17 '19 15:09 simontomaskarlsson

can you please give me the version of keras and keras-contrib which is used in this project

hala3 avatar Oct 01 '19 10:10 hala3

Hi @hala3,

The Keras version used was 2.1.2 and I believe the lastest Keras-contrib version should work.

simontomaskarlsson avatar Oct 01 '19 12:10 simontomaskarlsson

thank you for your reply. when i run the code it stopped and i show this message

Instructions for updating: keep_dims is deprecated, use keepdims instead --- Caching data --- Killed

can you help me to solve this problem

hala3 avatar Oct 02 '19 14:10 hala3

can i change the size to 300x300 maybe this is the problem when i run the code ; i make the size of input image to 300x300 so the process is killed

hala3 avatar Oct 02 '19 15:10 hala3

Try doing as the error suggests and change the function keep_dims to keepdims.

Changing the image size should not be a problem. Not all sizes will work though since the some operations in the model will pad the data if necessary which can lead to an altered output size.

simontomaskarlsson avatar Oct 03 '19 12:10 simontomaskarlsson

Hi @fdcqqqq,

I believe both errors come från the same problem. Since our reasearch never handled .tif images the load_data.py does not handle them. To fix this, modify on row 50 by changing:

if image_name[-1].lower() == 'g':

to

if image_name[-1].lower() == 'f':

I have't tried this but I think the model should handle .tif as long as they are loaded correctly.

Regards, Simon

Dear Simon, Unfortunately, I have the same problem but by trying the above code, it is not solved.

hamyadkiani avatar Nov 11 '19 14:11 hamyadkiani

Hi @hamyadkiani,

@fdcqqqq Seemed to figure it out, what was your solution @fdcqqqq?

simontomaskarlsson avatar Nov 13 '19 20:11 simontomaskarlsson

I solved the problem by using the advice u provided.I think this problem has a close relationship to the image format.

fdcqqqq avatar Nov 17 '19 14:11 fdcqqqq

@simontomaskarlsson @hamyadkiani

fdcqqqq avatar Nov 17 '19 14:11 fdcqqqq

I solved the problem by using the advice u provided.I think this problem has a close relationship to the image format.

Could tell me what‘s your image format?nii or hdr or any other?

Onlyuuuu avatar Dec 23 '21 12:12 Onlyuuuu