Skip to content

Commit 300cac4

Browse files
committed
new code for new updates
1 parent 512a037 commit 300cac4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

learner/learner.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77
import os
88
import time
9-
import cv2 # install cv3, python3: http://seeb0h.github.io/howto/howto-install-homebrew-python-opencv-osx-el-capitan/
9+
import cv2 # install cv3, python3: brew install opencv3 --with-contrib --with-python3 --without-python
1010
# add to profile: export PYTHONPATH=$PYTHONPATH:/usr/local/Cellar/opencv3/3.2.0/lib/python3.6/site-packages/
1111
import numpy as np
1212
from scipy.spatial import distance
@@ -128,10 +128,12 @@ def computeOutVar(path):
128128
pframe = cv2.resize(frame, dsize=(args.size, args.size))
129129

130130
# prepare and normalize frame for processing:
131-
pframe = np.swapaxes(pframe, 0, 2)
132-
pframe = np.expand_dims(pframe, axis=0)
131+
# pframe = np.swapaxes(pframe, 0, 2)
132+
# pframe = np.expand_dims(pframe, axis=0)
133+
# print(pframe)
133134
pframe = transformsImage(pframe)
134135
pframe = torch.autograd.Variable(pframe) # turn Tensor to variable required for pytorch processing
136+
pframe = pframe.unsqueeze(0)
135137

136138
# process via CNN model:
137139
output = model(pframe)
@@ -142,7 +144,7 @@ def computeOutVar(path):
142144
output = output.data.numpy()[0] # get data from pytorch Variable, [0] = get vector from array
143145

144146
# detect key presses:
145-
keyPressed = cv2.waitKey(33)
147+
keyPressed = cv2.waitKey(1)
146148
if keyPressed == ord('1'):
147149
protos[:,0] = output
148150
print("Learned object 1")

0 commit comments

Comments
 (0)