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

solved the issue of not being able to load weights due to different n… #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added __pycache__/test.cpython-36.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions b64_util.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions cannyedgedet.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
im = cv2.dilate(edges, cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(5, 5)), iterations=2)

new_img = copy.deepcopy(im)
contours, hierarchy = cv2.findContours(new_img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
_,contours, hierarchy = cv2.findContours(new_img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
#im = cv2.drawContours(im, contours, -1, (120,120,120), 6)

arr = []
Expand All @@ -46,7 +46,7 @@
k+=1
if k == 0:
arrnew.append(arr[i])
print arrnew
print(arrnew)



Expand All @@ -61,7 +61,7 @@
#cv2.imshow("Name", im)
cv2.imwrite("roi.jpg", roi)
test.testing(model)
cv2.waitKey(0)
# cv2.waitKey(0)



80 changes: 80 additions & 0 deletions cannyedgedet_b64.py

Large diffs are not rendered by default.

Binary file added new.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added roi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added roi1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added roi2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added roi3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 39 additions & 12 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from keras.callbacks import TensorBoard
from keras.models import Sequential, Model
from keras.layers import Dense,Dropout,Flatten,Conv2D,MaxPooling2D, Input, Conv3D
from keras.layers import Dense,Dropout,Flatten,Conv2D,MaxPooling2D, Input, Conv3D,BatchNormalization, Activation
from keras.optimizers import Adam
from keras.callbacks import ModelCheckpoint
from keras.utils import np_utils
from keras.preprocessing import image
from keras import optimizers
import keras
import pandas as pd
import cv2
Expand Down Expand Up @@ -43,23 +44,49 @@ def export_model(saver, model, input_node_names, output_node_name):


def model():
# model = Sequential()
# model.add(Conv2D(32, kernel_size=(3, 3),
# activation='relu',
# input_shape=(28, 28, 1)))
# model.add(Conv2D(64, (3, 3), activation='relu'))
# model.add(MaxPooling2D(pool_size=(2, 2)))
# model.add(Dropout(0.25))
# model.add(Flatten())
# model.add(Dense(128, activation='relu'))
# model.add(Dropout(0.5))
# model.add(Dense(47, activation='softmax'))

# model.compile(loss=keras.losses.categorical_crossentropy,
# optimizer=keras.optimizers.Adadelta(),
# metrics=['accuracy'])

model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3),
activation='relu',
input_shape=(28, 28, 1)))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(Conv2D(32, 3, 3, border_mode='valid', input_shape=(28, 28, 1)))
model.add(BatchNormalization())
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Activation("relu"))
model.add(Conv2D(32, 3, 3, border_mode='valid'))
model.add(Dropout(0.25))
model.add(BatchNormalization())
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.3))
model.add(Flatten())
model.add(Dense(1024, activation='relu'))
model.add(BatchNormalization())
model.add(Dropout(0.4))
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(47, activation='softmax'))
model.add(BatchNormalization())
model.add(Dropout(0.4))
model.add(Dense(47))
model.add(BatchNormalization())
model.add(Activation("softmax"))

adam = optimizers.Adam(lr=0.001, beta_1=0.9, beta_2=0.999, epsilon=None, decay=1e-6, amsgrad=False)
model.compile(optimizer=adam, loss='categorical_crossentropy', metrics=['accuracy'])

model.compile(loss=keras.losses.categorical_crossentropy,
optimizer=keras.optimizers.Adadelta(),
metrics=['accuracy'])
model.load_weights("output/Weights.h5")
print model.summary
# print model.summary
return model


Expand All @@ -80,7 +107,7 @@ def testing(model):
x /= 255
out = model.predict(x)

print dictionary[np.argmax(out)]
print(dictionary[np.argmax(out)])

if __name__=="__main__":
model = model()
Expand Down