Closed AnqiZou77 closed 6 years ago
@CocaKoala7 I initially preprocessed the original images as 1 channel (generated from preprocess.py ) and then changed it to 3 channels (generated from preprocess2.py). I suppose you were dealing with 3 channels as well. You can check the difference of Data_generator class between "train_net.py" (dealing with 1 channel) and "train_initial_net.py" (dealing with 3 channels).
Thank you very very much for your answer, that helps a lot~ I am implementing the CheXnet on the database Chest-X-Ray14 in which I found the images are grayscale images. Is that mean I just need to process the images as 1 channel? And I have another question. After I preprocessed the images as 1 channel(generated from preprocess.py), and run the ' train_initial_net.py' (it seems like this code is dealing with 1 channel). But there is another error "error when checking input: expected data to have shape (none, 224,224,3), but got array with shape(16,224,224,1)". I find the error may cause by the parameter 'concat_axis' in the subfunction 'cheX_net.py' , I changed 'concat_axis = 3' into 'concat_axis=1', and the 'shape=(224,224,3)' into 'shape=(224,224,2)', Is that right? and is there anything else I need to change? Thank you again for your answer~
@CocaKoala7 Actually, it depends on you to choose 1 channel or 3 channels. I chose 3 channels so that I could use the weights pretrained on ImageNet. If you want to use 1 channel, change the channel to 1 in cheX_net.py
:
if K.image_dim_ordering() == 'tf':
concat_axis = 3
img_input = Input(shape=(224, 224, 1), name='data')
else:
concat_axis = 1
img_input = Input(shape=(1, 224, 224), name='data')
concat_axis
means the axis of channel. The default value in tensorflow backend should be 3.
My data comes from the dataset Chest-X-Ray14 in which the images are 1024*1024 png. Do you use the same database? My understanding of the channel is that the grayscle image has 1 channel and the color image has 3 channel R-G-B. Is that right? Thank you for your answer~
@CocaKoala7 Yes, I used the the same data and you are right about channel, but the concat_axis
doesn't mean the number of channel, it means which axis in tensor is channel (also feature maps) axis.
then , why the grayscale images can be processed as 3 channel?
simply add two more the same channels as the first channel
ok, thank you very much~
Hi, When I run the "train_initial_net.py" in the cheX_net project, there is a problem"could not broadcast input array from shape (224,224,3) into shape (224,224)". I run the project on windows10 with python 3.6, tensorflow1.2.1, keras2.1.2. Thank you for your sharing. I am looking forwar to having your help.
a beginner for deep learning