-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_train.py
52 lines (42 loc) · 1.32 KB
/
main_train.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
41
42
43
44
45
46
47
48
49
50
51
52
from flask import Flask, render_template, request
from werkzeug import secure_filename
from PIL import Image
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D, BatchNormalization
from keras.layers import Activation, Dropout, Flatten, Dense
from keras.preprocessing.image import ImageDataGenerator
from keras.models import load_model, model_from_json
import numpy as np
import cv2
import webcolors
import time, os
import sys, h5py
import shutil
import random
np.random.seed(0)
from image_preprocess import crack_detection_preprocess_image
from image_preprocess import move_files_test_folder
from image_preprocess import preprocess_img
from CNNclassifier import training
os.environ['KMP_DUPLICATE_LIB_OK']='True'
app = Flask(__name__)
# root
@app.route("/")
def index():
"""
this is a root dir of my server
:return: str
"""
return '''This is training API :
To start training, go to http://127.0.0.1:5000/crack_detection_train'''
@app.route('/crack_detection_train')
def train_cnn():
no_files = crack_detection_preprocess_image()
# print(type(no_files), no_files)
to_move = float(no_files)*0.2
# print(int(to_move), type(to_move))
move_files_test_folder(int(to_move))
training()
return 'Training successful'
if __name__ == '__main__':
app.run(debug=True)