Skip to content

VisionAI-USF/COCO_Size_Decoding

Repository files navigation

Size encoding/decoding in COCO dataset

This code was used in the paper [1] as part of experiments to answer a question if size of an object can be encoded in an image by resampling (rescaling) the image. This code uses COCO dataset (http://cocodataset.org/). For our experiments we used three categories. Nevertheless, the code provides tools for repeating the described experiments with all categories that defined in the dataset. Moreover, some filtering tools are also provided.

Required Libraries


To process the COCO dataset we used COCO API library probided by the COCO team (https://github.com/cocodataset/cocoapi/).
NOTE: COCO API library is not supported for Windows OS.
Tensorflow version: 1.11.0
Keras version: 2.2.4
Python: 3.6.7
sklearn: 0.20.0

Execution parameters


--tmp_dir:<path to a directory>
The command is not required. Takes as an argument path to a folder.
Define Working Derectory.The application stores intermediate data as well as results of experiments in files. By default all the data is stored in the same folder where the code is located. Because it can be messy if several experiments performed each experiment can be assigned to a particular forlder such that all temporal and resulting data will be stored in the defined folder.
Example:
python3 main.py --tmp_dir:./experiment1/
Will create experiment1 folder and will store there all temporal results.

--load
The command is not required. Takes no arguments.
If provided then application will load COCO dataset from the Internet. Result will be stored to <Working Derectory>/data/ folder. Note: default tools provide small downloading speed as well as there were cases of connection errors that required to restart loading again. Thus, we recommend download COCO source files manually and place them in <Working Derectory>/data/ folder.
The application requires:
2014 Train images (http://images.cocodataset.org/zips/train2014.zip).
2014 Validation images (http://images.cocodataset.org/zips/val2014.zip).
2017 Train images (http://images.cocodataset.org/zips/train2017.zip).
2017 Validation images (http://images.cocodataset.org/zips/val2017.zip).
2014 Train/Val annotations (http://images.cocodataset.org/annotations/annotations_trainval2014.zip).
2017 Train/Val annotations (http://images.cocodataset.org/annotations/annotations_trainval2017.zip).

--unzip_preloaded
The command is required if all data files were downloaded manually. If defined, application will unzip all the files from <Working Derectory>/data/ folder.
Unzip source files.

--category:<category1,category2,...,category_n>
The command is not required. Takes as an argument a list of category names provided in COCO dataset and which must be used for experiments in the application.
COCO team annotated multiple objects from multiple categories (http://cocodataset.org/#explore). In our experiments we used three categories: cat, bear, dog. They are used as default categories.
Example:
python3 main.py --category:person,backpack,bicycle
Set the application to perform the experiments on person,backpack,bicycle categories.

--filter
The command is required. Takes no argument.
Filter images of defined object categories. After filtering compute the largest bounding box resolution for each category.
Example:
python3 main.py --filter
Create a folder and store objects images of defined categories.

--resize:<Integer value: rescaling resolution>
The command is required. Rescale filtered images to the uniform size. Images will be rescaled into square image with image size equal to defined values. NOTE:In our experiments we used 640x640 pixel image resolution as an input for the CNN. Thus, usage other values but 640 require changes in code i.e. change CNN input image size.
Example:
python3 main.py --resize:640
Resize filtered images into 640x640 images. Result will be used in the experiment.

--smallest_axe:<Integer value: the smallest height/width image value>
The command is not required. Remove from the dataset images which height or width is smaller than defined value.
Example:
python3 main.py --smallest_axe:80
Remove images which height or width is smaller than 80 pixels.

--largest_axe:<Integer value: the largers height/width image value>
The command is not required. Remove from the dataset images which height or width is larger than defined value.
Example:
python3 main.py --largest_axe:600
Remove images which height or width is larger than 600 pixels.

--median:<Integer value: percent value of images in the dataset>
The command is not required. Labeling of images is done automatically. The median area of a source images before rescaling is used as a threshold for labeling. It may create cases where two images with a small difference in area are labeled into different classes. This command create a margine between two classes by removing defined percent of images which are the closest in term of area to the median.
Example:
python3 main.py --median:5
Remove 5 percent of the dataset images which area is closest to the dataset median value.

--run_cv
The command is required. Takes no arguments. Perform 5 times 2-fold cross-validation on the resulting dataset and computes CNN output predictions as well as accuracy for each cross-validation iteration for each defined category.
Example:
python3 main.py --run_cv
Perform 5 times 2-fold cross-validation.

--auc
The command is not required. Takes no argumens.
Has to be executed if/after "--run_cv" is performed. If defined, then application will compute Area Under Receiver Operating Characteristic Curve (AUROC) for each iteration of cross-valitation of for each selected category. Example:
python3 main.py --auc
Computes AUROC for each iteration of cross-valitation of for each selected category.

--regression
The command is required. Takes no arguments. Perform 5 times 2-fold cross-validation regression training on the resulting dataset for each cross-validation iteration for each defined category.
Example:
python3 main.py --regression
Perform 5 times 2-fold cross-validation regression training.

--mse
The command is not required. Takes no argumens.
Has to be executed if/after "--regression" is performed. If defined, then application will compute Mean Square Error for the regression and Pearson Correlation Coefficient for labels and predictions. Example:
python3 main.py --mse
Computes AUROC for each iteration of cross-valitation of for each selected category.



Examples:
It is possible to run the application iteratively. First is it possible to download the dataset and then, with the second run, filter categories from the dataset. Nevertheless, we recommend to run the application with all the defined parameters at once. For example, in case when the required files are manually downloaded the experement performace can be done by running following command:
python3 main.py --unzip_preloaded --filter --resize:640 --run_cv --tmp_dir:./example_dir/
The application will unzip COCO dataset files from the ./example_dir/data/ folder and perform the experiment.
For filtering, the same command can be modified:
python3 main.py --unzip_preloaded --filter --resize:640 --run_cv --tmp_dir:./example_dir/ --smallest_axe:80 --median:10
The application will unzip COCO dataset files from the ./example_dir/data/ folder, remove images according to defined filtering commands and perform the experiment.

Issues


In case if you have problems with running the code, please contact the corresponding authore of the paper [1].

Reference


[1] Cherezov D, Paul R, Fetisov N, Gillies RJ, Schabath MB, Goldgof DB, Hall LO. Lung nodule sizes are encoded when scaling CT image for CNN's. Tomography. 2020 Jun;6(2):209.

Citation


If you use this results of this code in your work, please cite it as:

Cherezov D, Paul R, Fetisov N, Gillies RJ, Schabath MB, Goldgof DB, Hall LO. Lung nodule sizes are encoded when scaling CT image for CNN's. Tomography. 2020 Jun;6(2):209.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages