Example #1
0
        Console.log("Test Acc:", score[1])

    if args["predict"] != None and args["predict"] != "False":
        if args["predict"] != "True":
            Console.info("Predict for", args["predict"])
        else:
            Console.info("Predict...")
            # new instance where we do not know the answer
            Xnew = X_train
            Xnew = np.array(Xnew)

            # make a prediction
            ynew = model.predict(Xnew)

            error_count = 0
            for i in range(len(ynew)):
                predict = 1 if ynew[i][0] > 0.5 else 0
                if y_train[i] != predict:
                    error_count = error_count + 1
                    Console.error(
                        "ID:",
                        i,
                        "Original",
                        y_train[i],
                        "Predict",
                        predict,
                        "-",
                        str(math.trunc(ynew[i][0] * 100) / 100),
                    )
            Console.wran("Img with error", error_count)
    Console.info("Fix image colors")
    X_img = processeImg(files, y_lower_upper)

    Console.info("Run model_valid_hand")
    files = []
    X_to_predict = []
    for img_file, img, hist in X_img:
        files.append((img_file, img))
        X_to_predict.append(hist)
    X_to_predict = np.array(X_to_predict)
    # make a prediction
    y_valid_hand = model_valid_hand.predict(X_to_predict)

    Console.info("Saveing image..")
    total_file = len(files)
    for i in range(total_file):
        img_file, img = files[i]
        progress = float(i / total_file), (i + 1)
        # updateProgress(progress[0], progress[1], total_file, img_file)
        if y_valid_hand[i][0] > 0.5:
            path = os.path.join(__location__, "deep_fight", "hand", img_file)
        else:
            path = os.path.join(__location__, "deep_fight", "not_hand", img_file)
        cv2.imwrite(path, img)
        if y_valid_hand[i][0] < 0.6 and y_valid_hand[i][0] > 0.4:
            Console.wran("Image:", img_file, "hand valid:", y_valid_hand[i][0])
    # updateProgress(1, total_file, total_file, img_file)
    Console.info("Proeces", total_file, "images")

# para creae las iagenes en capetas separadas