Beispiel #1
0
    def build(self, input_shape):
        theta = np.array(range(self.K)) / self.K * np.pi
        self.contrast_gb = GaborFilters(self.ksize,
                                        theta=theta,
                                        octave=self.use_octave)

        self.contrast_BU = BotUpSaliency(self.ksize,
                                         K=self.K,
                                         steps=self.n_steps,
                                         epsilon=self.epsilon)
Beispiel #2
0
# img = np.zeros((256, 256, 3))
# img[:128, :128, 0] = 255
# img[128:, 128:, 1] = 255
# plt.imshow(img)

# -----------------   build model   ---------------
# build model
input = Input(shape=(256, 256, 3))

# -------------------- Gabor 1 ------------------ #
conf = config['Gabor'][0]
n_rot = conf['n_rot']
thetas = np.array(range(n_rot)) / n_rot * np.pi
gabor_layer1 = GaborFilters((15, 15),
                            theta=thetas,
                            sigma=conf['sigmas'],
                            lamda=np.array(conf['lamdas']) * np.pi,
                            gamma=conf['gamma'],
                            per_channel=False)
x1 = gabor_layer1(input)

# -------------------- Gabor 2 ------------------ #
conf = config['Gabor'][1]
n_rot = conf['n_rot']
thetas = np.array(range(n_rot)) / n_rot * np.pi
gabor_layer2 = GaborFilters((15, 15),
                            theta=thetas,
                            sigma=conf['sigmas'],
                            lamda=np.array(conf['lamdas']) * np.pi,
                            gamma=conf['gamma'],
                            per_channel=False)
x2 = gabor_layer2(input)
# img = np.zeros((256, 256, 3))
# img[:128, :128, 0] = 255
# img[128:, 128:, 1] = 255
# plt.imshow(img)

# build model
input = Input(shape=(256, 256, 3))

n_rot = 8
thetas = np.array(range(n_rot)) / n_rot * np.pi
sigmas = config['sigmas']
lamdas = np.array(config['lamdas']) * np.pi
gamma = config['gamma']
gabor_layer = GaborFilters((15, 15),
                           theta=thetas,
                           sigma=sigmas,
                           lamda=lamdas,
                           gamma=gamma,
                           per_channel=False)
x = gabor_layer(input)
# print("shape gabor_kernel", np.shape(gabor_layer.kernel))

# g_kernels = np.moveaxis(gabor_layer.kernel, -1, 0)
# for gb in g_kernels:
#     if np.shape(gb)[-1] == 1:
#         gb = np.squeeze(gb)
#     gb = (gb+1)/2
#     plt.figure()
#     plt.imshow(gb.astype(np.float32))
# plt.show()

model = Model(inputs=input, outputs=x)
Beispiel #4
0
# build model
input = Input(shape=(256, 256, 3))

n_rot = config['n_rot']
thetas = np.array(range(n_rot)) / n_rot * np.pi
lamdas = np.array(config['lamdas']) * np.pi
gamma = config['gamma']
phi = np.array(config['phi']) * np.pi
use_octave = config['use_octave']
octave = config['octave']
gabor_layer = GaborFilters((15, 15),
                           theta=thetas,
                           lamda=lamdas,
                           gamma=gamma,
                           phi=phi,
                           use_octave=use_octave,
                           octave=octave,
                           per_channel=False,
                           per_color_channel=True)
x = gabor_layer(input)
# print("shape gabor_kernel", np.shape(gabor_layer.kernel))

g_kernels = np.moveaxis(gabor_layer.kernel, -1, 0)
# for gb in g_kernels:
#     if np.shape(gb)[-1] == 1:
#         gb = np.squeeze(gb)
#     gb = (gb+1)/2
#     plt.figure()
#     plt.imshow(gb.astype(np.float32))
# plt.show()