-
Notifications
You must be signed in to change notification settings - Fork 1
/
Test.py
101 lines (76 loc) · 2.76 KB
/
Test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import matplotlib
import cv2
from tensorflow.keras.preprocessing.image import ImageDataGenerator
import matplotlib.pyplot as plt
import numpy as np
import argparse
import pickle
import os
import math
import tensorflow as tf
import Fetcher
import Model
import Config
from tqdm.autonotebook import tqdm
fetcher = Fetcher.DataFetcher();
#fetcher.processAndSave();
#fetcher.loadGestures(gestures= ["1","2"]);
fetcher.load();
model = Model.Net(numBatchTrain = 0);
model.network.summary();
model.load_checkpoint();
numSamples = 10;
for i in range(numSamples):
image, labels = fetcher.getRandomValidation();
_,out = model.validStep(input = image,label = labels);
a = out.numpy();
print(out.numpy().argmax(axis=1));
print(labels.numpy().argmax(axis=1));
print("===");
# print("[INFO]epoch : {}".format(i))
# for step in tqdm(range(numIterationEpochTrain)):
# image, labels ,size = fetcher.fetchTrain(Config.BATCH_SIZE);
# #image = tf.convert_to_tensor(image);
# loss,out = model.trainStep(input = image,label = labels);
# GT = np.array(labels).argmax(axis=1);
# Pred = out.numpy().argmax(axis=1);
# acc = 0;
# for a in range(size):
# if(GT[a] == Pred[a]):
# acc+=1;
# acc = acc / size;
# with model.summary_writer.as_default():
# tf.summary.scalar("loss", loss.numpy(), step= i*numIterationEpochTrain + step)
# tf.summary.scalar("acc", acc, step= i*numIterationEpochTrain + step)
# model.summary_writer.flush()
# loss = loss.numpy();
# allLossTrain.append(loss);
# allAccTrain.append(acc);
# for step in tf.range(numIterationEpochValid, dtype=tf.int64):
# image, labels, size = fetcher.fetchValid(Config.BATCH_SIZE);
# #image = tf.convert_to_tensor(image);
# loss,out = model.validStep(input = image,label = labels);
# GT = GT = np.array(labels).argmax(axis=1);
# Pred = out.numpy().argmax(axis=1);
# acc = 0;
# for a in range(size):
# if(GT[a] == Pred[a]):
# acc+=1;
# acc = acc / size;
# with model.summary_writer.as_default():
# tf.summary.scalar("lossValid", loss.numpy(), step= i*numIterationEpochValid + step)
# tf.summary.scalar("accValid", acc, step= i*numIterationEpochValid + step)
# model.summary_writer.flush()
# loss = loss.numpy();
# allLossValid.append(loss);
# allAccValid.append(acc);
# print("loss train:{}".format(np.mean(allLossTrain)));
# print("accuracy train:{}".format(np.mean(allAccTrain)));
# print("loss valid:{}".format(np.mean(allLossValid)));
# print("accuracy valid:{}".format(np.mean(allAccValid)));
# print("==================================");
# allLossTrain = [];
# allAccTrain = [];
# allLossValid = [];
# allAccValid = [];
# model.save_checkpoint(step = i);