File size: 692 Bytes
8fcfb0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import shutil


if __name__ == "__main__":

    print("Convert model labels to human readable")

    source_file = 'config.json'
    old_file = 'config.json.bak'
    
    shutil.copyfile(source_file, old_file)

    LABEL_TO_CHAR = {
        "LABEL_0" : "0",
        "LABEL_1" : ".",
        "LABEL_2" : ",",
        "LABEL_3" : "?",
        "LABEL_4" : "-",
        "LABEL_5" : ":"
    }


    with open(old_file, 'r') as fp_input, open(source_file, 'w') as fp_output:
        lines = fp_input.readlines()
        for line in lines:
            for label in LABEL_TO_CHAR.keys():
                line = line.replace(label, LABEL_TO_CHAR[label])

            fp_output.write(line)