Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MatchNet: Keras implementation #13

Open
memon-aliraza opened this issue Oct 9, 2019 · 0 comments
Open

MatchNet: Keras implementation #13

memon-aliraza opened this issue Oct 9, 2019 · 0 comments

Comments

@memon-aliraza
Copy link

Hi,

I am trying to re-write the network architecture in Keras. Please help me to review the following network architecture. The network contain two-different image types(i-e: the images taken from the camera (cam_input) and its corresponding CAD model image (cad_image)).

import os
import itertools
import numpy as np
from PIL import Image
from keras import backend as K
from keras.models import Model, Sequential
import matplotlib.pyplot as plt
from keras.optimizers import Adam
from sklearn.utils import shuffle
from keras.callbacks import TensorBoard
from keras.layers.merge import concatenate
from sklearn.metrics import confusion_matrix
from keras.layers import Input, Lambda, Dense, Flatten, Reshape, Conv2D, MaxPool2D

# input image size and channels
img_width, img_height, channels = 64, 64, 3

cam_input = Input(shape=(img_width,img_height,channels))
cad_input = Input(shape=(img_width,img_height,channels))

def feature_net(input_data):
    conv0 = Conv2D(24, kernel_size=7, strides=(1,1), padding = 'SAME', activation='relu')(input_data)
    pool0 = MaxPool2D((3, 3), strides=(2, 2), padding = 'SAME')(conv0)
    
    conv1 = Conv2D(64, kernel_size=5, strides=(1,1), padding = 'SAME', activation='relu')(pool0)
    pool1 = MaxPool2D((3, 3), strides=(2, 2), padding = 'SAME')(conv1)
    
    conv2 = Conv2D(96, kernel_size=3, strides=(1,1), padding = 'SAME', activation='relu')(pool1)
    
    conv3 = Conv2D(96, kernel_size=3, strides=(1,1), padding = 'SAME', activation='relu')(conv2)
    
    conv4 = Conv2D(64, kernel_size=3, strides=(1,1), padding = 'SAME',  activation='relu')(conv3)
    pool4 = MaxPool2D((3, 3), strides=(2, 2), padding = 'SAME')(conv4)
    
    return Reshape([4096])(pool4)

cam_fv = feature_net(cam_input)
cad_fv = feature_net(cad_input)

merge = concatenate([cam_fv, cad_fv])

# Similarity network
fc1 = Dense(1024, activation='relu', name='fc1')(merge)
fc2 = Dense(1024, activation='relu', name='fc2')(fc1)
output = Dense(2, activation='softmax', name='fc3')(fc2)

matchnet = Model(inputs=[cam_input, cad_input], outputs=output)
print(matchnet.summary())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant