simontomaskarlsson / GAN-MRI

Code repository for Frontiers article 'Generative Adversarial Networks for Image-to-Image Translation on Multi-Contrast MR Images - A Comparison of CycleGAN and UNIT'
GNU General Public License v3.0
227 stars 77 forks source link

some error about running code #12

Open fdcqqqq opened 5 years ago

fdcqqqq commented 5 years ago

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~

simontomaskarlsson commented 5 years ago

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

fdcqqqq commented 5 years ago

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.

simontomaskarlsson commented 5 years ago

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

fdcqqqq commented 5 years ago

ok,thanks.

fdcqqqq commented 5 years ago

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.

simontomaskarlsson commented 5 years ago

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?

fdcqqqq commented 5 years ago

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.

simontomaskarlsson commented 5 years ago

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.

hala3 commented 5 years ago

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

simontomaskarlsson commented 5 years ago

Hi @hala3,

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

hala3 commented 5 years ago

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 commented 5 years ago

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

simontomaskarlsson commented 5 years ago

Try doing as the error suggests and change the function _keepdims 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.

hamyadkiani commented 5 years ago

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.

simontomaskarlsson commented 5 years ago

Hi @hamyadkiani,

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

fdcqqqq commented 5 years ago

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

fdcqqqq commented 5 years ago

@simontomaskarlsson @hamyadkiani

Onlyuuuu commented 2 years ago

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?