-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.py
40 lines (32 loc) · 925 Bytes
/
run.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
import os
import tqdm
import joblib
import train_distributions
import preprocess
import cv2
import train_contour
import warnings
MODELS_PATH = "models"
def run():
print("Preprocessing train images...")
try:
os.mkdir(preprocess.PREPROCESSED_PATH)
os.mkdir(MODELS_PATH)
except:
pass
for ind in tqdm.tqdm(range(1, 791)):
im = preprocess.read_im(ind, preprocessed=False)
proc = preprocess.full_pipeline(im)
try:
cv2.imwrite(os.path.join(preprocess.PREPROCESSED_PATH, f"{ind}.jpg"), proc)
except Exception as e:
print(e)
import sys
sys.exit(-1)
dist_model = train_distributions.get_trained_model()
path = os.path.join(MODELS_PATH, "regr_tree.model")
joblib.dump(dist_model, path)
print("Model saved at ", path)
if __name__ == "__main__":
warnings.filterwarnings("ignore")
run()