Skip to content

Commit c119198

Browse files
committed
IssueFix: Traning new gesture got broken due to my earlier commit. Its fixed with this commit.
1 parent 0fb93e9 commit c119198

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

gestureCNN.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def modlistdir(path, pattern = None):
142142

143143

144144
# Load CNN model
145-
def loadCNN():
145+
def loadCNN(bTraining = False):
146146
global get_output
147147
model = Sequential()
148148

@@ -173,21 +173,22 @@ def loadCNN():
173173
# Model conig details
174174
model.get_config()
175175

176-
177-
#List all the weight files available in current directory
178-
WeightFileName = modlistdir('.','.hdf5')
179-
if len(WeightFileName) == 0:
180-
print('Error: No pretrained weight file found. Please either train the model or download one from the https://github.com/asingh33/CNNGestureRecognizer')
181-
return 0
182-
else:
183-
print('Found these weight files - {}'.format(WeightFileName))
184-
#Load pretrained weights
185-
w = int(input("Which weight file to load (enter the INDEX of it, which starts from 0): "))
186-
fname = WeightFileName[int(w)]
187-
print("loading ", fname)
188-
model.load_weights(fname)
189-
190-
layer = model.layers[11]
176+
if not bTraining :
177+
#List all the weight files available in current directory
178+
WeightFileName = modlistdir('.','.hdf5')
179+
if len(WeightFileName) == 0:
180+
print('Error: No pretrained weight file found. Please either train the model or download one from the https://github.com/asingh33/CNNGestureRecognizer')
181+
return 0
182+
else:
183+
print('Found these weight files - {}'.format(WeightFileName))
184+
#Load pretrained weights
185+
w = int(input("Which weight file to load (enter the INDEX of it, which starts from 0): "))
186+
fname = WeightFileName[int(w)]
187+
print("loading ", fname)
188+
model.load_weights(fname)
189+
190+
# refer the last layer here
191+
layer = model.layers[-1]
191192
get_output = K.function([model.layers[0].input, K.learning_phase()], [layer.output,])
192193

193194

trackgesture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def Main():
206206
mod = myNN.loadCNN()
207207
break
208208
elif ans == 2:
209-
mod = myNN.loadCNN()
209+
mod = myNN.loadCNN(True)
210210
myNN.trainModel(mod)
211211
input("Press any key to continue")
212212
break

0 commit comments

Comments
 (0)