def __init__(self, signal_images_list, bkg_image_list, json_name):
        """
        Args:
            csv_file (string): Path to the csv file with annotations.
            root_dir (string): Directory with all the images.
            transform (callable, optional): Optional transform to be applied
                on a sample.
        """

        signal_dict = create_table(signal_images_list, (json_name, 'id'))
        background_dict = create_table(bkg_image_list, (json_name, 'id'))
        try:
            print('clock: ', background_dict['clock'][0])
        except:
            '''
            '''
        # print(signal_dict[json_name][1])
        # assert 0
        signal_images = np.array(signal_dict[json_name], dtype=object)
        background_images = np.array(background_dict[json_name], dtype=object)
        dataset_size = min(len(signal_images), len(background_images))
        signal_labels = np.ones(dataset_size, dtype=np.float32)
        background_labels = np.zeros(dataset_size, dtype=np.float32)
        self.size = dataset_size * 2
        self.trainX = np.concatenate(
            (signal_images[:dataset_size], background_images[:dataset_size]),
            axis=0)
        print(self.trainX.shape)
        self.trainY = np.concatenate((signal_labels, background_labels),
                                     axis=0)
        self.image_shape = (self.trainX.shape[-1], *self.trainX[0, 0].shape)
예제 #2
0
    def __init__(self, signal_images_list, bkg_image_list, json_name):
        """
        Args:
            csv_file (string): Path to the csv file with annotations.
            root_dir (string): Directory with all the images.
            transform (callable, optional): Optional transform to be applied
                on a sample.
        """

        signal_dict = create_table(signal_images_list, (json_name, 'vertex'))
        background_dict = create_table(bkg_image_list, (json_name, 'vertex'))
        signal_images = np.array(signal_dict[json_name], dtype=object)
        background_images = np.array(background_dict[json_name], dtype=object)
        dataset_size = min(len(signal_images), len(background_images))
        signal_labels = np.ones(dataset_size, dtype=np.float32)
        background_labels = np.zeros(dataset_size, dtype=np.float32)
        self.size = dataset_size * 2
        indices = np.arange(self.size)
        np.random.shuffle(indices)
        self.trainX = np.concatenate(
            (signal_images[:dataset_size], background_images[:dataset_size]),
            axis=0)[indices]
        self.trainY = np.concatenate((signal_labels, background_labels),
                                     axis=0)[indices]
        self.image_shape = (self.trainX.shape[-1], *self.trainX[0, 0].shape)
예제 #3
0
    def __init__(self, signal_images_list, bkg_image_list, json_name):

        signal_dict = create_table(signal_images_list, (json_name, 'id'))
        background_dict = create_table(bkg_image_list, (json_name, 'id'))
        signal_images = np.array(signal_dict[json_name], dtype=object)
        background_images = np.array(background_dict[json_name], dtype=object)
        dataset_size = min(len(signal_images), len(background_images))
        signal_labels = np.ones(dataset_size, dtype=np.float32)
        background_labels = np.zeros(dataset_size, dtype=np.float32)
        self.size = dataset_size * 2
        self.trainX = np.concatenate(
            (signal_images[:dataset_size], background_images[:dataset_size]),
            axis=0)
        print(self.trainX.shape)
        self.trainY = np.concatenate((signal_labels, background_labels),
                                     axis=0)
        self.image_shape = (self.trainX.shape[-1], *self.trainX[0, 0].shape)
예제 #4
0
    def __init__(self, signal_images_list, bkg_image_list, json_name):

        signal_dict = create_table(signal_images_list, (json_name, 'vertex'))
        background_dict = create_table(bkg_image_list, (json_name, 'vertex'))
        print(len(signal_dict[json_name]))
        signal_images = np.array(signal_dict[json_name], dtype=object)
        background_images = np.array(background_dict[json_name], dtype=object)
        print(signal_images.shape, 'Abigail')
        dataset_size = min(len(signal_images), len(background_images))
        signal_labels = np.ones(dataset_size, dtype=np.float32)
        background_labels = np.zeros(dataset_size, dtype=np.float32)
        self.size = dataset_size * 2
        indices = np.arange(self.size)
        np.random.shuffle(indices)
        print(signal_images.shape, background_images.shape)
        self.trainX = np.concatenate(
            (signal_images[:dataset_size], background_images[:dataset_size]),
            axis=0)[indices]
        self.trainY = np.concatenate((signal_labels, background_labels),
                                     axis=0)[indices]
        self.image_shape = (self.trainX.shape[-1], *self.trainX[0, 0].shape)
예제 #5
0
    time_index = args.time_index
    qe_index = args.qe_index
    json_name = str(time_index) + '_' + str(qe_index)
    signal_images_list = [
        str(filename.strip()) for filename in list(open(args.signallist, 'r'))
        if filename != ''
    ]
    bkg_image_list = [
        str(filename.strip()) for filename in list(open(args.bglist, 'r'))
        if filename != ''
    ]
    signal_images_list = signal_images_list[:1]
    bkg_image_list = bkg_image_list[:1]

    signal_dict = create_table(signal_images_list, (json_name, 'vertex'))
    background_dict = create_table(bkg_image_list, (json_name, 'vertex'))
    signal_images = np.array(signal_dict[json_name], dtype=object)
    background_images = np.array(background_dict[json_name], dtype=object)
    print(len(signal_images), len(background_images))
    dataset_size = min(len(signal_images), len(background_images))
    signal_labels = np.ones(dataset_size, dtype=np.float32)
    background_labels = np.zeros(dataset_size, dtype=np.float32)
    size = dataset_size * 2
    indices = np.arange(size)
    np.random.shuffle(indices)
    trainX = np.concatenate(
        (signal_images[:dataset_size], background_images[:dataset_size]),
        axis=0)[indices]
    trainY = np.concatenate((signal_labels, background_labels),
                            axis=0)[indices]