示例#1
0
def straight_flames():
    import os
    os.chdir(os.path.dirname(os.path.abspath(__file__)))

    model = Model(n_characters, n_hidden, n_characters, n_layers)
    model.load("models/wtchrrnn.pt")

    return " ".join(model.generate("Add ", 40).split(" ")[:-1]).strip() + "."
示例#2
0
    else: y = 0
    h += 2 * CropPadding
    if x > CropPadding: x = x - CropPadding
    else: x = 0
    w += 2 * CropPadding
    return [x, y, w, h]


if __name__ == '__main__':
    # Change working directory
    os.chdir(os.path.dirname(os.path.realpath(__file__)))

    cap = cv2.VideoCapture(0)

    model = Model()
    model.load()

    # Get Cascade Classifier
    cascade = cv2.CascadeClassifier(cascade_path)

    isme = 0
    notme = 0

    nDelay = 0

    # Run window in other thread
    cv2.startWindowThread()

    while True:
        _, frame = cap.read()
示例#3
0
from train import Model
from preprocess import constructTensors

model = Model()
model.load('parameters')
Input, Output = constructTensors()
print(model.forward(Input))
print(Output)
示例#4
0
        if file.endswith('.jpg') or file.endswith('.png'):
            print('test %s' % file)
            file_path = os.path.abspath(os.path.join(path, file))
            image = read_image(file_path)
            result = model.predict(image)
            index = np.argmax(result)
            print(classes[index], result[index])


if __name__ == '__main__':
    classes = []
    parser = argparse.ArgumentParser()
    parser.add_argument('--predict_dir', type=str, help='folder of images')
    args = parser.parse_args()
    if args.predict_dir:
        model = Model()
        try:
            model.load(file_path=args.predict_dir + '\model.h5')
            with open(args.predict_dir + '\labels.txt', 'r') as f:
                for line in f.readlines():
                    classes.append(line.strip())
        except OSError as e:
            print(
                "<--------------------Unable to open file-------------------->\n",
                e)
        else:
            prediction(args.predict_dir, classes)
    else:
        print(
            'Input no found\nTry "python predict.py -h" for more information')
示例#5
0
    model = Model(n_characters, n_hidden, n_characters, n_layers)
    model.load("models/wtchrrnn.pt")

    return " ".join(model.generate("Add ", 40).split(" ")[:-1]).strip() + "."


if __name__ == "__main__":
    argparser = argparse.ArgumentParser()
    argparser.add_argument('--model',
                           type=str,
                           default="save/char-rnn-gru.pt",
                           help="Path to trained model")
    argparser.add_argument(
        '--prime',
        type=str,
        required=True,
        help="Prime string to predict next sequence of characters")
    argparser.add_argument('--len',
                           type=int,
                           default=1000,
                           help="Predict string length")
    args = argparser.parse_args()

    warnings.filterwarnings("ignore")

    model = Model(n_characters, n_hidden, n_characters, n_layers)
    model.load(args.model)

    print(model.generate(args.prime, args.len))