-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload.py
More file actions
58 lines (49 loc) · 1.38 KB
/
Copy pathload.py
File metadata and controls
58 lines (49 loc) · 1.38 KB
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
import sys
import numpy as np
import string
import scipy.special
import itertools
def loadTrainTest(pathT,pathE):
fT=open(pathT,'r')
fE=open(pathE,'r')
DTR=[]
DTE=[]
LTE=[]
LTR=[]
for line in fT:
splitted=line.split(',')
DTR.append([float(i) for i in splitted[:-1]])
LTR.append(int(splitted[-1]))
DTR=np.array(DTR)
LTR=np.array(LTR)
for line in fE:
splitted=line.split(',')
DTE.append([float(i) for i in splitted[:-1]])
LTE.append(int(splitted[-1]))
DTE=np.array(DTE)
LTE=np.array(LTE)
fT.close()
fE.close()
return (DTR, LTR),(DTE,LTE)
def mcol(v):
return v.reshape((v.size, 1))
#qui trovi un caricamento di un solo file
def loadFile(fname):
DList = []
labelsList = []
hLabels = {
'Spoofed fingerprint': 0,
'Authentic fingerprint': 1,
}
with open(fname) as f:
for line in f:
try:
attrs = line.split(',')[0:4]
attrs = mcol(np.array([float(i) for i in attrs]))
name = line.split(',')[-1].strip()
label = hLabels[name]
DList.append(attrs)
labelsList.append(label)
except:
pass
return np.hstack(DList), np.array(labelsList, dtype=np.int32)