-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccuracyTesting.py
62 lines (55 loc) · 1.98 KB
/
AccuracyTesting.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
import os
import sys
import time
import subprocess
## MUST run from conda activated terminal
##
## Run in the same folder as VTSC.exe and TSAnalysis.py
## Switch unconverted true/false if the files to test are mp4 or folder format
givenDir = sys.argv[1]
givenModel = sys.argv[2]
if(not os.path.isdir(givenDir)):
print("exit - not folder")
sys.exit()
correct = 0
wrong = 0
total = 0
unconverted = False
outputFile = open("testingOutput.txt", "w")
fileHeader = "FILE \t\t\t| SYS PREDICTION \t| SYS CORRECT"
print(fileHeader)
outputFile.write(fileHeader+"\n")
start = time.time()
for subItem in os.listdir(givenDir):
subItem = givenDir+"/"+subItem
if(unconverted):
if(os.path.isdir(subItem)): continue
process = subprocess.run(['VTSC.exe',subItem,givenModel], stdout=subprocess.PIPE)
output = process.stdout.decode('utf-8').splitlines()
result = output[len(output)-2]
else:
if(not os.path.isdir(subItem)): continue
process = subprocess.run(['python','TSAnalysis.py',subItem,givenModel], stdout=subprocess.PIPE)
output = process.stdout.decode('utf-8').splitlines()
result = output[len(output)-1]
if(result=="CORRECT" and ("_C_" in subItem)):
correct += 1
output = "CORRECT"
elif(result=="INCORRECT" and ("_I_" in subItem)):
correct += 1
output = "CORRECT"
else:
wrong += 1
output = "INCORRECT"
total += 1
itemResult = subItem + " \t| " + result + " \t\t| "+ output
print(itemResult)
outputFile.write(itemResult+"\n")
end = time.time()
time = (end-start)/total
percentage = (correct/total)*100
testingResults = "\nCorrect: "+str(correct)+"\t Wrong: "+str(wrong)+"\t Total: "+str(total)+"\t Accuracy: "+str(round(percentage, 2))+"%\tTime per classify: " +str(round(time,2))+"s"
print(testingResults)
print("Total time: " + str((end-start)) +"s")
outputFile.write(testingResults)
outputFile.close()