-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8982050
commit deff070
Showing
10 changed files
with
183 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,6 @@ | |
@license: Licensed under the Apache License v2.0. http://www.apache.org/licenses/ | ||
@contact: [email protected] | ||
@version: 1.2 | ||
@create: June 27, 2018 | ||
@updated: July 06, 2018 | ||
Tasks: | ||
The program implementation will classify input image by a trained model and generate mask image as | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,37 @@ | |
This is the main file for the project. From here you can train, test, and manipulate the SegCaps of models. | ||
Please see the README for detailed instructions for this project. | ||
============== | ||
This is the entry point of the package to train UNet, tiramisu, Capsule Nets (capsbasic) or SegCaps(segcapsr1 or segcapsr3). | ||
@author: Cheng-Lin Li a.k.a. Clark | ||
@copyright: 2018 Cheng-Lin Li@Insight AI. All rights reserved. | ||
@license: Licensed under the Apache License v2.0. http://www.apache.org/licenses/ | ||
@contact: [email protected] | ||
Tasks: | ||
The program load parameters for training, testing, manipulation for all models. | ||
Data: | ||
MS COCO 2017 or LUNA 2016 were tested on this package. | ||
You can leverage your own data set but the mask images should follow the format of MS COCO or with background color = 0 on each channel. | ||
Enhancement: | ||
1. The program was modified to support python 3.6 on Ubuntu 18.04 and Windows 10. | ||
2. Support not only 3D computed tomography scan images but also 2D Microsoft Common Objects in COntext (MS COCO) dataset images. | ||
3. Add Kfold parameter for users to customize the cross validation task. K = 1 will force model to perform overfit. | ||
4. Add retrain parameter to enable users to reload pre-trained weights and retrain the model. | ||
5. Add initial learning rate for users to adjust. | ||
6. Add steps per epoch for users to adjust. | ||
7. Add number of patience for early stop of training to users. | ||
8. Add 'bce_dice' loss function as binary cross entropy + soft dice coefficient. | ||
9. Revise 'train', 'test', 'manip' flags from 0 or 1 to flags show up or not to indicate the behavior of main program. | ||
''' | ||
|
||
from __future__ import print_function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,31 @@ | |
If you have any questions, please email me at [email protected]. | ||
This file is used for testing models. Please see the README for details about testing. | ||
============== | ||
This is the entry point of the test procedure for UNet, tiramisu, Capsule Nets (capsbasic) or SegCaps(segcapsr1 or segcapsr3). | ||
@author: Cheng-Lin Li a.k.a. Clark | ||
@copyright: 2018 Cheng-Lin Li@Insight AI. All rights reserved. | ||
@license: Licensed under the Apache License v2.0. http://www.apache.org/licenses/ | ||
@contact: [email protected] | ||
Tasks: | ||
The program based on parameters from main.py to perform testing tasks on all models. | ||
Data: | ||
MS COCO 2017 or LUNA 2016 were tested on this package. | ||
You can leverage your own data set but the mask images should follow the format of MS COCO or with background color = 0 on each channel. | ||
Enhancement: | ||
1. Integrated with MS COCO 2017 dataset. | ||
''' | ||
|
||
from __future__ import print_function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,29 @@ | |
This file is used for training models. Please see the README for details about training. | ||
Enhancement: Integrated with MS COCO dataset. | ||
============== | ||
This is the entry point of the train procedure for UNet, tiramisu, Capsule Nets (capsbasic) or SegCaps(segcapsr1 or segcapsr3). | ||
@author: Cheng-Lin Li a.k.a. Clark | ||
@copyright: 2018 Cheng-Lin Li@Insight AI. All rights reserved. | ||
@license: Licensed under the Apache License v2.0. http://www.apache.org/licenses/ | ||
@contact: [email protected] | ||
Tasks: | ||
The program based on parameters from main.py to perform training tasks on all models. | ||
Data: | ||
MS COCO 2017 or LUNA 2016 were tested on this package. | ||
You can leverage your own data set but the mask images should follow the format of MS COCO or with background color = 0 on each channel. | ||
Enhancement: | ||
1. Integrated with MS COCO 2017 dataset. | ||
''' | ||
|
||
from __future__ import print_function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,27 @@ | |
If you have any questions, please email me at [email protected]. | ||
This file contains the custom data augmentation functions. | ||
===== | ||
This program includes all data augmentation functions UNet, tiramisu, Capsule Nets (capsbasic) or SegCaps(segcapsr1 or segcapsr3). | ||
@author: Cheng-Lin Li a.k.a. Clark | ||
@copyright: 2018 Cheng-Lin Li@Insight AI. All rights reserved. | ||
@license: Licensed under the Apache License v2.0. http://www.apache.org/licenses/ | ||
@contact: [email protected] | ||
Enhancement: | ||
1. add image2float_array | ||
2. add image_resize2square: Convert any size of image file to 512 X 512 resolutions | ||
3. add image_enhance function to sifht image color space includes background color | ||
4. add process_image to wrap image color shifting and resize the resolutions | ||
5. add change_background_color to change mask background color of MS COCO files to black | ||
6. add convert_mask_data function to resize and change mask color to black | ||
7. add convert_img_data function to wrap process_image, normalized data, reshape to require dimension 3 or 4 | ||
''' | ||
|
||
import numpy as np | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,22 @@ | |
If you have any questions, please email me at [email protected]. | ||
This file contains the definitions of custom loss functions not present in the default Keras. | ||
===== | ||
This program includes all custom loss functions UNet, tiramisu, Capsule Nets (capsbasic) or SegCaps(segcapsr1 or segcapsr3). | ||
@author: Cheng-Lin Li a.k.a. Clark | ||
@copyright: 2018 Cheng-Lin Li@Insight AI. All rights reserved. | ||
@license: Licensed under the Apache License v2.0. http://www.apache.org/licenses/ | ||
@contact: [email protected] | ||
Enhancement: | ||
1. Revise default loss_type to jaccard on dice_soft function. | ||
2. add bce_dice_loss for future usage. | ||
''' | ||
|
||
import tensorflow as tf | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
''' | ||
This program is a helper to separate the codes of 2D and 3D image processing. | ||
@author: Cheng-Lin Li a.k.a. Clark | ||
This is a helper file for choosing which dataset functions to create. | ||
@copyright: 2018 Cheng-Lin Li@Insight AI. All rights reserved. | ||
@license: Licensed under the Apache License v2.0. http://www.apache.org/licenses/ | ||
@contact: [email protected] | ||
Tasks: | ||
The program is a helper to separate the codes of 2D and 3D image processing. | ||
This is a helper file for choosing which dataset functions to create. | ||
''' | ||
import logging | ||
import utils.load_3D_data as ld3D | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
''' | ||
Capsules for Object Segmentation (SegCaps) | ||
Original Paper by Rodney LaLonde and Ulas Bagci (https://arxiv.org/abs/1804.04241) | ||
Code written by: Rodney LaLonde | ||
If you use significant portions of this code or the ideas from our paper, please cite it :) | ||
If you have any questions, please email me at [email protected]. | ||
This file is used for loading training, validation, and testing data into the models. | ||
It is specifically designed to handle 3D single-channel medical data. | ||
Modifications will be needed to train/test on normal 3-channel images. | ||
Enhancement: | ||
0. Porting to Python version 3.6 | ||
1. Add image_resize2square to accept any size of images and change to 512 X 512 resolutions. | ||
2. | ||
This program includes all functions of 2D color image processing for UNet, tiramisu, Capsule Nets (capsbasic) or SegCaps(segcapsr1 or segcapsr3). | ||
@author: Cheng-Lin Li a.k.a. Clark | ||
@copyright: 2018 Cheng-Lin Li@Insight AI. All rights reserved. | ||
@license: Licensed under the Apache License v2.0. http://www.apache.org/licenses/ | ||
@contact: [email protected] | ||
Tasks: | ||
The program based on parameters from main.py to load 2D color image files from folders. | ||
The program will convert all image files into numpy format then store training/testing images into | ||
./data/np_files and training (and testing) file lists under ./data/split_list folders. | ||
You need to remove these two folders every time if you want to replace your training image and mask files. | ||
The program will only read data from np_files folders. | ||
Data: | ||
MS COCO 2017 or LUNA 2016 were tested on this package. | ||
You can leverage your own data set but the mask images should follow the format of MS COCO or with background color = 0 on each channel. | ||
Features: | ||
1. Integrated with MS COCO 2017 dataset. | ||
2. Use PILLOW library instead of SimpleITK for better support on RasberryPi | ||
3. add new generate_test_image function to process single image frame for video stream | ||
''' | ||
|
||
from __future__ import print_function | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,34 +9,49 @@ | |
It is specifically designed to handle 3D single-channel medical data. | ||
Modifications will be needed to train/test on normal 3-channel images. | ||
===== | ||
This program includes all functions of 3D image processing for UNet, tiramisu, Capsule Nets (capsbasic) or SegCaps(segcapsr1 or segcapsr3). | ||
@author: Cheng-Lin Li a.k.a. Clark | ||
@copyright: 2018 Cheng-Lin Li@Insight AI. All rights reserved. | ||
@license: Licensed under the Apache License v2.0. http://www.apache.org/licenses/ | ||
@contact: [email protected] | ||
Tasks: | ||
The program based on parameters from main.py to load 3D image files from folders. | ||
The program will convert all image files into numpy format then store training/testing images into | ||
./data/np_files and training (and testing) file lists under ./data/split_list folders. | ||
You need to remove these two folders every time if you want to replace your training image and mask files. | ||
The program will only read data from np_files folders. | ||
Data: | ||
MS COCO 2017 or LUNA 2016 were tested on this package. | ||
You can leverage your own data set but the mask images should follow the format of MS COCO or with background color = 0 on each channel. | ||
Enhancement: | ||
0. Porting to Python version 3.6 | ||
1. Add image_resize2square to accept any size of images and change to 512 X 512 resolutions. | ||
2. | ||
1. Porting to Python version 3.6 | ||
2. Remove program code cleaning | ||
''' | ||
|
||
from __future__ import print_function | ||
|
||
import logging | ||
from os.path import join, basename | ||
from os import makedirs | ||
# from glob import glob | ||
# import csv | ||
# from sklearn.model_selection import KFold | ||
|
||
import numpy as np | ||
from numpy.random import rand, shuffle | ||
import SimpleITK as sitk | ||
# from sklearn.model_selection import train_test_split | ||
# from tqdm import tqdm #Progress bar | ||
|
||
# import matplotlib | ||
# matplotlib.use('Agg') | ||
import matplotlib.pyplot as plt | ||
# import cv2 | ||
|
||
plt.ioff() | ||
|
||
# from keras.preprocessing.image import * | ||
from utils.custom_data_aug import augmentImages | ||
from utils.threadsafe import threadsafe_generator | ||
|
||
|