'Skip if already calculated and saved before', action="store_true")
    parser.add_argument(
        '--plot_prob',
        help=
        'Plot the graphs of probability of choosing each image vs. fixations',
        action="store_true")
    parser.add_argument(
        '--plot_acc',
        help=
        'Plot the graphs of prediction accuracy of the network vs. fixations',
        action="store_true")

    args = parser.parse_args()

    # Load data
    load_data = LoadData()
    slide_sequences, slide_selections = load_data.get_RNN_data_selection()
    max_sequence_lengths = load_data.get_max_sequence_lengths()
    NUM_SUBJECTS = slide_selections.shape[1]
    _, _, _, corr_imgs = load_data.get_other_var()

    if args.from_scratch:
        #Load models
        network = Network()
        network.load_models("SELECTION")
        models = network.get_models(
        )  #NUM_SLIDES x k model (each slide has k folds)

        stratified_kfold = StratifiedKFold(n_splits=k,
                                           shuffle=True,
                                           random_state=seed)
Beispiel #2
0
from utils.ablation_utils import modify_all_sequences
from baseline_model.baseline_model import BaselineModel

import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
plt.ion()

from sklearn.model_selection import StratifiedKFold
from keras.preprocessing.sequence import pad_sequences

seed = 7

model_type_name = 'SELECTION'

load_data = LoadData()
slide_sequences, slide_selections = load_data.get_RNN_data() if (
    model_type_name == 'CORRECT') else load_data.get_RNN_data_selection()

##### #####
discard_last_dup_sequences = modify_all_sequences(slide_sequences,
                                                  num_last_arg=None,
                                                  mode='discard last dup',
                                                  section=None)
print('slide_sequences[0][0]: ', slide_sequences[0][0])
print('discard_last_dup_sequences[0][0]: ', discard_last_dup_sequences[0][0])
print('slide_sequences[9][9]: ', slide_sequences[9][9])
print('discard_last_dup_sequences[9][9]: ', discard_last_dup_sequences[9][9])
slide_sequences = discard_last_dup_sequences
##### #####
Beispiel #3
0
        'Skip if already have network trained and saved prior', action="store_true")
    parser.add_argument('--conf',
                        help='Show confusion matrices',
                        action="store_true")
    parser.add_argument('--acc', help='Show accuracies', action="store_true")
    parser.add_argument('--auc', help='Show auc_scores', action="store_true")
    parser.add_argument('--plot_val_loss',
                        help='Plot validation losses',
                        action="store_true")
    parser.add_argument('--output',
                        help='Output dataframes to csv files',
                        action="store_true")

    args = parser.parse_args()

    load_data = LoadData()
    slide_sequences, slide_labels = load_data.get_RNN_data()

    network = Network()

    if args.train:
        network.train_and_save(slide_sequences,
                               slide_labels,
                               "CORRECT",
                               should_save_auc=True)
    else:
        network.load_results("CORRECT")

    if args.conf:
        print('DISPLAYING CONFUSION MATRICES:\n')
        conf = network.get_confusion_matrices()
Beispiel #4
0
    help_method =   "1. Shuffle whole sequence\n"+\
                    "2. Keep only 1st half\n"+\
                    "3. Keep only 2nd half\n"+\
                    "4. Shuffle 1st half and keep 2nd half\n"+\
                    "5. Shuffle 2nd half and keep 1st half\n"+\
                    "6. Discard 1st half and shuffle 2nd half\n"+\
                    "7. Discard last 5 fixations"
    parser.add_argument('method', choices=range(1,8), help=help_method, type=int)
    
    parser.add_argument('--conf', help='Show confusion matrices', action="store_true")
    parser.add_argument('--acc', help='Show accuracies', action="store_true")
    parser.add_argument('--auc', help='Show auc_scores', action="store_true")
    
    model_type_name = "CORRECT"
    print("model_type_name: ", model_type_name)
    load_data = LoadData()
    if model_type_name == "SELECTION":
        slide_sequences, slide_labels = load_data.get_RNN_data_selection()
    else:
        slide_sequences, slide_labels = load_data.get_RNN_data()
    max_sequence_lengths = load_data.get_max_sequence_lengths()

    args = parser.parse_args()
    
    
    
    network = Network()
    network.load_models(model_type_name)
    model = network.get_models()
    
    method = int(args.method)
Beispiel #5
0
    args = parser.parse_args()
    num_features = args.num_features
    feature = None
    if num_features == '1c':
        num_features = 1
        feature = 'correct'
    elif num_features == '1m':
        num_features = 1
        feature = 'master'
    elif num_features == '1l':
        num_features = 1
        feature = 'length'
    else:
        num_features = int(num_features)

    load_data = LoadData()
    slide_sequences, slide_selections = load_data.get_RNN_data_selection()
    num_incorrect, easy_slides, hard_slides, correct_images = load_data.get_other_var(
    )

    baseline_model = BaselineModel()
    baseline_model.train(slide_sequences, slide_selections, correct_images,
                         num_features, feature)

    if args.conf:
        print('DISPLAYING CONFUSION MATRICES:\n')
        conf = baseline_model.get_confusion_matrices()
        for slide_id in range(NUM_SLIDES):
            print('Slide ' + str(slide_id + 1) + ':\n', conf[slide_id])

    if args.acc: