Skip to content

Commit 0b9600b

Browse files
Sylwester DawidaSylwester Dawida
Sylwester Dawida
authored and
Sylwester Dawida
committed
big update changet tranfrorms
1 parent bc542ca commit 0b9600b

17 files changed

+188
-75
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ python/data
99
python/kinect_leap_dataset
1010
python/openCvTranforms
1111
python/laRED_dataset
12-
kivy_venv
12+
kivy_venv
13+
doc

python/.idea/workspace.xml

+43-34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
245 Bytes
Binary file not shown.
18 Bytes
Binary file not shown.
270 Bytes
Binary file not shown.
5 Bytes
Binary file not shown.
Binary file not shown.

python/datasetLoader.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,23 @@ def __getitem__(self, idx):
114114
split = 2
115115
import openCvTranforms.opencv_transforms.transforms as tf
116116

117-
heigh = 60
118-
width = 60
117+
heigh = 200
118+
width = 200
119119

120120

121121
def imshow(img):
122-
# img = img.view(3, heigh, width, 1). / 2 + 0.5 # unnormalize
122+
img = img[0].permute(1, 2, 0).numpy() / 2 + 0.5
123+
# img = img.view(heigh, width, 3).numpy() # unnormalize
123124
print(img.shape)
124-
# npimg = img.numpy()
125-
cv2.imshow("preview", img.numpy())
125+
cv2.imshow("preview", img)
126126

127127

128128
transform = transforms.Compose(
129-
[tf.Resize((heigh, width)),
129+
[tf.RandomCrop([400, 400]),
130+
tf.Resize((heigh, width)),
131+
tf.ColorJitter(brightness=0.5, contrast=0.5),
130132
tf.ToTensor(),
131-
tf.Normalize((0.5,), (0.5,))
133+
tf.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
132134
])
133135
dir = "D:/DataSetNew/"
134136
testDataset = myDataset(dir, split, test=True, transform=transform)
@@ -145,5 +147,10 @@ def imshow(img):
145147
num_workers=4)
146148

147149
trainLoader = torch.utils.data.DataLoader(trainDataset,
148-
batch_size=1, shuffle=True,
150+
batch_size=1, shuffle=False,
149151
num_workers=4)
152+
153+
for data in trainLoader:
154+
images, labels = data
155+
imshow(images)
156+
cv2.waitKey(0)

python/gestureRecorder.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from time import time
77
from enum import Enum
88
from comunication import Commands
9+
910
if __name__ == '__main__':
1011

1112
device = cv2.VideoCapture(0, cv2.CAP_DSHOW)
@@ -62,6 +63,7 @@ class pearsons(Enum):
6263
AD = "AD"
6364
KH = "KH"
6465

66+
6567
"""
6668
default = 1
6769
turnLeft = 2
@@ -81,8 +83,8 @@ class pearsons(Enum):
8183
add = True
8284
# if false all files in existing dir will be deleted
8385
saving = True
84-
command = commands.stopCommand
85-
pearson = pearsons.JD
86+
command = commands.slowDown
87+
pearson = pearsons.KH
8688
howMany = 100
8789
savePerSec = 12.0
8890
##end settigns
@@ -109,7 +111,7 @@ class pearsons(Enum):
109111
print("Old files deleted")
110112
print("files: {}".format(file))
111113
print("Creating dataset. Gesture: {}. Pearson: {}".format(command.name, pearson.name))
112-
check = cv2.imread("D:\DataSetNew\{}\SD\{}_1.jpg".format(command.name,command.value))
114+
check = cv2.imread("D:\DataSetNew\{}\SD\{}_1.jpg".format(command.name, command.value))
113115
frameWithStats = cv2.flip(check, 1)
114116
frameWithStats = drawStatistics(frameWithStats, out, 1)
115117
cv2.imshow("AllImage", frameWithStats)

python/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(self, print):
5252
self.transform = transforms.Compose([
5353
tf.Resize((self.heigh, self.width)),
5454
tf.ToTensor(),
55-
tf.Normalize((0.5,), (0.5,))
55+
tf.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
5656
])
5757
self.signals = Signals()
5858
self.running = True

python/mainCuda.py

+25-12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import openCvTranforms.opencv_transforms.transforms as tf
1010
import torchvision.transforms as transforms
1111
import keyboard
12+
from resultsPresentation import updating
1213

1314

1415
# plot image with opencv
@@ -54,6 +55,8 @@ def train(net, epochs, startingEpoch):
5455
if startEpoch > epochs:
5556
return epochs + 1
5657

58+
plot = updating()
59+
5760
with open(logFile, "a") as f:
5861
for epoch in range(startingEpoch, EPOCHS):
5962
print("\aepoch: " + str(epoch))
@@ -73,11 +76,12 @@ def train(net, epochs, startingEpoch):
7376

7477
acc, loss = fwd_pass(images, labels, train=True)
7578

76-
if i % 80 == 79:
77-
val_acc, val_loss = test(64)
79+
if i % 100 == 99:
80+
val_acc, val_loss = test()
7881
# print(val_acc, float(val_loss))
7982
f.write(
8083
f"{MODEL_NAME},{round(time.time(), 3)},{round(float(acc), 3)}, {round(float(loss), 4)}, {round(float(val_acc), 3)}, {round(float(val_loss), 4)}, {epoch}\n")
84+
plot.update(acc, loss, val_acc, val_loss)
8185
i += 1
8286
t.close()
8387
if exit:
@@ -86,7 +90,7 @@ def train(net, epochs, startingEpoch):
8690

8791

8892
class globNr(object):
89-
nr = 19
93+
nr = 21
9094

9195

9296
if __name__ == "__main__":
@@ -103,21 +107,30 @@ class globNr(object):
103107
modelFilename = "./savedMode{}.pth".format(nr)
104108
dataSetPath = "D:/DataSetNew/"
105109
logFile = 'model{}.log'.format(nr)
106-
loadTrainData = True
110+
loadTrainData = False
107111
split = 1
108112
width = 60
109113
heigh = 60
110114
epochs = 10
111-
batchSize = 15
115+
batchSize = 30
112116
startEpoch = 0
113-
114-
transform = transforms.Compose(
115-
[tf.Resize((heigh, width)),
116-
tf.ToTensor(),
117-
tf.Normalize((0.5,), (0.5,))])
118-
117+
drawing = False
118+
119+
transform = transforms.Compose([
120+
tf.Resize((heigh, width)),
121+
tf.ToTensor(),
122+
tf.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
123+
])
124+
125+
trainTransform = transforms.Compose([
126+
tf.RandomCrop([400, 400]),
127+
tf.Resize((heigh, width)),
128+
tf.ColorJitter(brightness=0.5, contrast=0.5),
129+
tf.ToTensor(),
130+
tf.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
131+
])
119132
testLoader = myDataset(dataSetPath, split, test=True, transform=transform)
120-
trainLoader = myDataset(dataSetPath, split, test=False, transform=transform)
133+
trainLoader = myDataset(dataSetPath, split, test=False, transform=trainTransform)
121134
print("test {}, train {}".format(len(testLoader), len(trainLoader)))
122135
testDataset = torch.utils.data.DataLoader(testLoader,
123136
batch_size=batchSize, shuffle=True)

python/model20.log

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
model-1578229518,1578229670.18,0.1, 0.0709, 0.13, 0.0717, 0
2+
model-1578229518,1578229799.806,0.133, 0.0707, 0.166, 0.0698, 0
3+
model-1578229518,1578229918.962,0.3, 0.0647, 0.185, 0.0689, 0
4+
model-1578229518,1578230022.535,0.167, 0.0708, 0.168, 0.0689, 0
5+
model-1578229518,1578230125.936,0.233, 0.062, 0.222, 0.0658, 0
6+
model-1578229518,1578230225.786,0.267, 0.0616, 0.215, 0.0651, 0
7+
model-1578229518,1578230321.838,0.133, 0.0671, 0.202, 0.0653, 0
8+
model-1578229518,1578230415.446,0.2, 0.0642, 0.204, 0.0655, 0
9+
model-1578229518,1578230501.56,0.267, 0.0662, 0.214, 0.0642, 0
10+
model-1578229518,1578230583.264,0.167, 0.0635, 0.236, 0.0623, 0
11+
model-1578229518,1578230663.222,0.133, 0.0637, 0.232, 0.063, 0
12+
model-1578229518,1578230726.592,0.167, 0.0641, 0.229, 0.0627, 1
13+
model-1578229518,1578230770.25,0.2, 0.0604, 0.234, 0.062, 1
14+
model-1578229518,1578230813.477,0.2, 0.0589, 0.24, 0.0621, 1
15+
model-1578229518,1578230857.516,0.133, 0.0664, 0.228, 0.0618, 1
16+
model-1578229518,1578230900.095,0.333, 0.0612, 0.239, 0.0618, 1
17+
model-1578229518,1578230945.273,0.133, 0.0679, 0.234, 0.0614, 1
18+
model-1578229518,1578230995.203,0.333, 0.0576, 0.258, 0.0615, 1
19+
model-1578229518,1578231048.311,0.267, 0.0576, 0.256, 0.0612, 1
20+
model-1578229518,1578231106.379,0.233, 0.0656, 0.278, 0.0608, 1
21+
model-1578229518,1578231174.712,0.2, 0.0639, 0.279, 0.0601, 1
22+
model-1578229518,1578231244.272,0.233, 0.0654, 0.289, 0.0591, 1
23+
model-1578231672,1578231722.662,0.133, 0.0662, 0.281, 0.0659, 0
24+
model-1578231672,1578231769.662,0.3, 0.0627, 0.441, 0.0535, 0
25+
model-1578231672,1578231821.712,0.467, 0.0557, 0.539, 0.0485, 0
26+
model-1578231672,1578231876.484,0.533, 0.0473, 0.632, 0.0404, 0
27+
model-1578231672,1578231944.577,0.667, 0.0415, 0.646, 0.0394, 0
28+
model-1578231672,1578232022.542,0.567, 0.0436, 0.744, 0.0311, 0
29+
model-1578231672,1578232107.579,0.633, 0.0344, 0.799, 0.0263, 0
30+
model-1578231672,1578232183.972,0.733, 0.0262, 0.808, 0.0238, 1
31+
model-1578231672,1578232217.037,0.633, 0.0343, 0.842, 0.0216, 1
32+
model-1578231672,1578232249.613,0.767, 0.0321, 0.869, 0.0192, 1
33+
model-1578231672,1578232283.161,0.7, 0.0338, 0.844, 0.0212, 1
34+
model-1578231672,1578232322.598,0.733, 0.0293, 0.853, 0.0192, 1
35+
model-1578231672,1578232370.007,0.733, 0.0263, 0.857, 0.0197, 1
36+
model-1578231672,1578232436.885,0.933, 0.0115, 0.903, 0.0157, 1
37+
model-1578231672,1578232512.7,0.9, 0.0156, 0.881, 0.017, 2
38+
model-1578231672,1578232548.062,0.833, 0.0223, 0.875, 0.0181, 2
39+
model-1578231672,1578232583.239,0.833, 0.0171, 0.891, 0.0152, 2
40+
model-1578231672,1578232620.201,0.833, 0.0184, 0.907, 0.0136, 2
41+
model-1578231672,1578232658.165,0.833, 0.0255, 0.905, 0.0141, 2
42+
model-1578231672,1578232701.094,0.8, 0.026, 0.898, 0.015, 2
43+
model-1578231672,1578232757.489,0.733, 0.0291, 0.921, 0.0131, 2
44+
model-1578233527,1578233556.541,0.067, 0.0709, 0.077, 0.0733, 0

python/model21.log

Whitespace-only changes.

0 commit comments

Comments
 (0)