Exemple #1
0
def criminalinfo():
    if 'auth' in session:
        try:
            c, conn = connection()
            if request.method == "POST":
                name = request.form['name']
                nic = request.form['nic']
                age = request.form['age']
                add01 = request.form['add01']
                add02 = request.form['add02']
                add03 = request.form['add03']
                eye = request.form['eye']
                hair = request.form['hair']
                gender = request.form['gender']

                data = c.execute("SELECT * FROM  criminalinfo WHERE nic=(%s)", (thwart(nic)))

                if int(data) > 0:
                    print(data)
                else:

                    c.execute(
                        "INSERT INTO  criminalinfo (nic,name,age,addressline01,addressline02,addressline03,eyecolor,haircolor,gender) values(%s,%s,%s,%s,%s,%s,%s,%s,%s)",
                        (thwart(nic), thwart(name), thwart(age), thwart(add01), thwart(add02), thwart(add03), thwart(eye),
                         thwart(hair), thwart(gender)))
                    conn.commit()
                    c.close()
                    conn.close()
                    target = os.path.join(APP_ROOT, 'uploads/train/' + nic)
                    print(target)
                    if not os.path.isdir(target):
                        os.mkdir(target)

                    count = 0
                    for file in request.files.getlist('img'):
                        print(file)
                        count = count + 1
                        filename = file.filename
                        print(filename)
                        destination = "/".join([target, filename])
                        print(destination)
                        file.save(destination)

                    # ttt
                    obj = preprocesses(TRAIN_FOLDER, PRE_FOLDER)
                    nrof_images_total, nrof_successfully_aligned = obj.collect_data()

                    print('Total number of images: %d' % nrof_images_total)
                    print('Number of successfully aligned images: %d' % nrof_successfully_aligned)

                    print("Training Start")
                    obj = training(PRE_FOLDER, MODEL_DIR, CLASSIFIER)
                    get_file = obj.main_train()
                    print('Saved classifier model to file "%s"' % get_file)

                    # flash('User registeration succeeded please log in', 's_msg')
                    return jsonify(success=["User Registration Success"], value=True)


        except Exception as e:
            return (str(e))
            print(e)

    else:
        return render_template("login.html", data="please log in")
    return render_template("criminalinfo.html")
Exemple #2
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import sys
from packages import classifier

datadir = './pre_img'
modeldir = './models/20170511-185253.pb'
classifier_filename = './class/classifier.pkl'
print("Training Start")
obj = classifier.training(datadir, modeldir, classifier_filename)
get_file = obj.main_train()
print('Saved classifier model to file "%s"' % get_file)
sys.exit("All Done")
import sys

from packages.classifier import training

datadir = './preprocessed_img'
modeldir = './models/20180408-102900'
classifier_filename = './class/classifier.pkl'
eval_score_path = './class/accuracy_score.txt'
print("Training Start")
obj = training(datadir, modeldir, classifier_filename, eval_score_path)
get_file = obj.main_train()
print('Saved classifier model to file "%s"' % get_file)
sys.exit("All Done")