This repository was archived by the owner on Oct 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessData.py
More file actions
executable file
·71 lines (59 loc) · 2.35 KB
/
Copy pathprocessData.py
File metadata and controls
executable file
·71 lines (59 loc) · 2.35 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
59
60
61
62
63
64
65
66
67
68
69
70
71
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
\file processData.py
\copyright Copyright (c) 2019 Visual Computing group of Ulm University,
Germany. See the LICENSE file at the top-level directory of
this distribution.
\author pedro hermosilla (pedro-1.hermosilla-casajus@uni-ulm.de)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
import sys
import math
import os
import numpy as np
from os import listdir
from os.path import isfile, join
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(ROOT_DIR, 'MCCNN/utils'))
from PyUtils import visualize_progress
def process_model(modelPath):
if not isfile(modelPath[:-4]+".npy"):
corrupt = False
fileDataArray = []
with open(modelPath, 'r') as modelFile:
it = 0
for line in modelFile:
line = line.replace("\n", "")
if ("nan" not in line) and ("inf" not in line):
currPoint = line.split(',')
try:
fileDataArray.append([float(currVal) for currVal in currPoint])
except ValueError:
corrupt = True
it+=1
if not(corrupt):
np.save(modelPath[:-4]+".npy", np.array(fileDataArray))
return corrupt
return False
def get_files():
fileList = []
dataFolders = ["ao_data", "gi_data", "sss_data"]
datasets = ["training", "evaluation", "test"]
for currDataFolder in dataFolders:
for currDataSet in datasets:
for f in listdir(currDataFolder+"/"+currDataSet) :
if isfile(join(currDataFolder+"/"+currDataSet+"/", f)) and f.endswith(".txt"):
fileList.append(join(currDataFolder+"/"+currDataSet+"/", f))
return fileList
if __name__ == '__main__':
fileList = get_files()
iter = 0
maxSize = 0.0
corruptFiles = []
for inFile in fileList:
if process_model(inFile):
corruptFiles.append(inFile)
if iter%100==0:
visualize_progress(iter, len(fileList))
iter = iter + 1
for currCorruptFile in corruptFiles:
print(currCorruptFile)
print(len(corruptFiles))