Example #1
0
    def rqst_train_exp(pid, expid):
        print("Training")
        try:
            db = get_db()
            #  status = getExpState(db, expid)
            (ganDir, ganFile, ganClass) = getGANInfo(db, expid)
            gan = create_gan_object(db, pid, expid, ganDir, ganFile, ganClass)
            # gan.run()
            x = threading.Thread(target=gan.run)
            x.start()
            setExpState(db, expid, "RETRAIN")

        except Exception as e:
            print(str(e))
Example #2
0
    def request_inference_generate(pid, expid, model_path):

        print("Request received to make inference plot")
        db = get_db()

        (ganDir, ganFile, ganClass) = getGANInfo(db, expid)
        # my_module = importlib.import_module("GANEX.fastGAN.{}".format(ganFile))
        # gan = eval("my_module.{}(db, pid, expid)".format(ganClass))
        gan = create_gan_object(db, pid, expid, ganDir, ganFile, ganClass)
        gan.inference(model_path)

        img_list = get_output_imgs(db, expid, "INFERENCED")

        emit("inference-get-inferenced-imgs", img_list, namespace='/inference')
        print(img_list)
Example #3
0
    def rqst_retrain_exp(pid, expid, model_path):
        print("Re-Training")
        print("Model path ", model_path)
        try:
            db = get_db()
            # status = getExpState(db, expid)
            (ganDir, ganFile, ganClass) = getGANInfo(db, expid)
            gan = create_gan_object(db, pid, expid, ganDir, ganFile, ganClass)
            # gan.rerun()
            x = threading.Thread(target=gan.rerun, args=(model_path, ))
            x.start()
            setExpState(db, expid, "RETRAIN")

        except Exception as e:
            print(str(e))
Example #4
0
    def generate_sample_img(pid, expid):
        db = get_db()
        # add image path to db
        # generateInputImageGrid(dataloader, imgpath, device)

        #===============================================
        # Use selected GAN image grid generate function
        #===============================================
        (ganDir, ganFile, ganClass) = getGANInfo(db, expid)
        # import gan from gan file
        #* my_module = importlib.import_module("GANEX.fastGAN.{}".format(ganFile))
        #* gan = eval("my_module.{}(db, pid, expid)".format(ganClass))
        gan = create_gan_object(db, pid, expid, ganDir, ganFile, ganClass)
        #gan.setDevice()
        #gan.prepareData()

        imgpath = addImage(db, expid, "INPUTDATA")

        gan.generate_input_image_grid(imgpath)

        img_path_list = getImagePaths(db, expid, "INPUTDATA")
        emit('data-get-img-paths', img_path_list, namespace='/data')
Example #5
0
def runexp(pid, expid):

    db = get_db()
    status = getExpState(db, expid)
    print("status:", status)

    if status == None:
        flash("status error")

    if request.method == "POST":
        print("POST request received")
        if request.form["runexp_btn"] == "train":

            try:
                # get the GAN class
                (ganDir, ganFile, ganClass) = getGANInfo(db, expid)
                print("gan Dir=", ganDir)
                print("gan file=", ganFile)
                print("gan class=", ganClass)

                # import gan from gan file
                #* my_module = importlib.import_module("GANEX.fastGAN.{}".format(ganFile))
                #* gan = eval("my_module.{}(db, pid, expid)".format(ganClass))
                gan = create_gan_object(db, pid, expid, ganDir, ganFile,
                                        ganClass)
                # gan.run("BTN_TRAIN")
                gan.run()

                setExpState(db, expid, "RETRAIN")

                #run(get_db(),pid, expid, status)
                print("Training")
                #setExpState(db, expid, "RETRAIN")
                #status = getExpState(db, expid)
            except Exception as e:
                flash(str(e))

        elif request.form["runexp_btn"] == "re-train":
            try:
                # get the GAN class
                (ganDir, ganFile, ganClass) = getGANInfo(db, expid)
                print("gan file=", ganFile)
                print("gan class=", ganClass)

                # import gan from gan file
                #* my_module = importlib.import_module("GANEX.fastGAN.{}".format(ganFile))
                #* gan = eval("my_module.{}(db, pid, expid)".format(ganClass))
                gan = create_gan_object(db, pid, expid, ganDir, ganFile,
                                        ganClass)
                # * gan.run("BTN_RETRAIN")
                gan.rerun()
                setExpState(db, expid, "RETRAIN")

                #run(get_db(),pid, expid, status)
                print("Training")
                #setExpState(db, expid, "RETRAIN")
                #status = getExpState(db, expid)
            except Exception as e:
                flash(str(e))

            print("Retraining")

        elif request.form["runexp_btn"] == "reset":

            print("Reset")
            delTrainStats(db, expid)
            setExpState(db, expid, "TRAIN")
            status = getExpState(db, expid)

            # reset default exp para
            exp_para_list = get_default_exp_para(db, pid)
            for exp_para in exp_para_list:
                temp_dict = {exp_para["para_key"]: exp_para["para_value"]}
                update_exp_info(db, expid, temp_dict)
                print("exp para :", exp_para)

    return render_template('run/runexp.html',
                           pid=pid,
                           expid=expid,
                           status=status)