File size: 1,730 Bytes
2eba0cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import argparse



def parse_args():
    """Parse input arguments."""
    parser = argparse.ArgumentParser(
        description='gaze estimation using binned loss function.')
    parser.add_argument(
        '--evalpath', dest='evalpath', help='path for evaluating gaze test.',
        default="evaluation\L2CS-gaze360-_standard-10", type=str)
    parser.add_argument(
        '--respath', dest='respath', help='path for saving result.',
        default="evaluation\L2CS-gaze360-_standard-10", type=str)

if __name__ == '__main__':

    args = parse_args()
    evalpath =args.evalpath
    respath=args.respath
    if not os.path.exist(respath):
            os.makedirs(respath)
    with open(os.path.join(respath,"avg.log"), 'w') as outfile:    
        outfile.write("Average equal\n")

        min=10.0
        dirlist = os.listdir(evalpath)
        dirlist.sort()
        l=0.0
        for j in range(50):
            j=20
            avg=0.0
            h=j+3
            for i in dirlist:
                with open(evalpath+"/"+i+"/mpiigaze_binned.log") as myfile:
                    
                    x=list(myfile)[h]
                    str1 = "" 
                    
                    # traverse in the string  
                    for ele in x: 
                        str1 += ele  
                    split_string = str1.split("MAE:",1)[1] 
                    avg+=float(split_string)

            avg=avg/15.0
            if avg<min:
                min=avg
                l=j+1
            outfile.write("epoch"+str(j+1)+"= "+str(avg)+"\n")

        outfile.write("min angular error equal= "+str(min)+"at epoch= "+str(l)+"\n")
    print(min)