juntang-zhuang / LadderNet

137 stars 36 forks source link

training on different database #10

Closed manvirvirk closed 4 years ago

manvirvirk commented 4 years ago

hi, i want to run laddernet on different images other than DRIVE. How to do that?

YrgkenKoutsi commented 4 years ago

Hi,

That is a good question indeed

If you noticed in the source code file prepare_datasets_DRIVE.py which is responsible of the dataset and the first step of running this model. You have path to images line 20-27 which defines training and testing the model in a specific way. This model is based on 3 sets of images, original images, ground truth and bordermask images. Unfortunately there are not many datasets that provide all these specification so you either need to find a way to extract ground truth and border mask from an retinal image or rewritte the code to read original images only which I have not yet figured a way around this.

Note that removing ground truth and border mask will affect the results dramatically as our purpose here is Retinal Blood Vessel Segmentation which means these attributes are essential to improving the acurracy of this model.

Let me know if you do find a way though :)

manvirvirk commented 4 years ago

yea facing this same issue, will go through it.

juntang-zhuang commented 4 years ago

Thanks for help @AnthonyKuci. It's basically as AnthonyKuci said.

manvirvirk commented 4 years ago

i have only database containing simple retina images without ground truth . how to segment them with ground truth and mask?

juntang-zhuang commented 4 years ago

It's impossible to generate ground truth with any model. Models can only generate predictions.

manvirvirk commented 4 years ago

i have generated masks of my database. So can you tell what changes need to be made in files?

YrgkenKoutsi commented 4 years ago

Happy to help @juntang-zhuang

it's quite easy @manvirvirk just change prepare_dataset_DRIVE.py as follows:

lines 19 to 28 change the path with your new image path or replace the images inside these folders

`------------Path of the images --------------------------------------------------------------

train

original_imgs_train = "./DRIVE/training/images/" groundTruth_imgs_train = "./DRIVE/training/1st_manual/" borderMasks_imgs_train = "./DRIVE/training/mask/"

test

original_imgs_test = "./DRIVE/test/images/" groundTruth_imgs_test = "./DRIVE/test/1st_manual/" borderMasks_imgs_test = "./DRIVE/test/mask/"

---------------------------------------------------------------------------------------------

`

change lines 30 to 34 Nimgs the number of images in your path, channels the dimension of your images this part will most likely throw you an ValueError: could not broadcast input array from shape (height, width, dimension ) into shape (height, width) *Note that images in DRIVE dataset are specific dimensions as such (584, 565, 3) and ground images and mask images are (584, 565, 1) if you do not have the same parameters this will not work

`Nimgs = 20 #number of iages channels = 3 #dimension height = 584 #this is for drive you must change it to your images or convert them t match its one width = 565 #this is for drive you must change it to your images or convert them t match its one

change the path below for your costume images or any other dataset you are using so you won't mix things up

dataset_path = "./DRIVE_datasets_training_testing/"`

FInally lines 50, 57, 59 need to be changed to your images name and type or match the existing ones as shown below:

` groundTruth_name = files[i][0:2] + "_manual1.gif"

border_masks_name = files[i][0:2] + "_training_mask.gif"

border_masks_name = files[i][0:2] + "_test_mask.gif"

`

I hope that help,

Good Luck

manvirvirk commented 4 years ago

@AnthonyKuci Thanks for reply. I have database of 20 images and corresponding masks on which i want to train this model. So i have to make these changes in prepare_dataset_DRIVE file.

manvirvirk commented 4 years ago

what all changes we need to make in retinaNN_train.py file?

YrgkenKoutsi commented 4 years ago

Only path related changes you would have to make if you change the path folder with your images this also includes configuration.txt file

manvirvirk commented 4 years ago

i m getting this error when i made the changes accirding to my data: original image: 1_training.png specify if train or test!!

YrgkenKoutsi commented 4 years ago

Is this error coming from prepare_dataset_Drive.py?

It seems to me that this is the case in which you most likely have not specified the path in your images. If you check the DRIVE folder it has a specific structure you must follow that structure to avoid error and further rearrangements in the source code.

all you need is the following structure:

-DRIVE ------test ------------images ------------1st_manual ------------mask ------training ------------images ------------1st_manual ------------mask

hope that helps

manvirvirk commented 4 years ago

actually i want to train on data which have only images and respective labels. I dont have 1st_manual so i deleted that line in code. Rest database directory is same

YrgkenKoutsi commented 4 years ago

Yeah, that should be fine if you apply the changes in the source code, however, *Note that this will affect the network dramatically.

manvirvirk commented 4 years ago

hi,i m using this to train on my database which have only images and mask. I have made changes in prepare dataset file. i m getting following error in training file: File "retinaNN_training.py", line 91, in inside_FOV = config.getboolean('training settings', 'inside_FOV') #select the patches only inside the FOV (default == True) File "C:\Users\virkt\Anaconda3\envs\laddernet\lib\configparser.py", line 828, in getboolean raw=raw, vars=vars, fallback=fallback, kwargs) File "C:\Users\virkt\Anaconda3\envs\laddernet\lib\configparser.py", line 808, in _get_conv kwargs) File "C:\Users\virkt\Anaconda3\envs\laddernet\lib\configparser.py", line 802, in _get return conv(self.get(section, option, **kwargs)) File "C:\Users\virkt\Anaconda3\envs\laddernet\lib\configparser.py", line 791, in get raise NoOptionError(option, section) configparser.NoOptionError: No option 'inside_fov' in section: 'training settings'