コード例 #1
0
ファイル: test.py プロジェクト: ceuity/auto_painter
def test():
    curr_time = time.time()
    image_path = args.path
    source = load_image(image_path)
    adjusted_image = preprocess(source, IMG_WIDTH, IMG_HEIGTH)
    image = denormalize(adjusted_image)
    result = generate_image(model, adjusted_image)
    image = Image.fromarray(result)
    image_path = './images/'
    filename = 'result_image.png'
    image.save(image_path + filename)
コード例 #2
0
def get_result():
    if request.method == "POST":
        width, height = 28, 28
        try:
            source = Image.open(request.files["source"])
            adjusted_img = preprocess(source, width, height)
            res = predict_number(model, adjusted_img, width, height)
        except Exception as e:
            print("error : %s" % e)
            return Response("fail", status=400)
    return str(res)
コード例 #3
0
ファイル: app.py プロジェクト: ceuity/auto_painter
def get_result():
    if request.method == "POST":
        width, height = 512, 512
        try:
            source = request.files['source'].read()
            adjusted_image = preprocess(source, width, height)
            image = denormalize(adjusted_image)
            result = generate_image(model, adjusted_image)
            image = Image.fromarray(result)
            image_path = './images/'
            filename = 'result_image.png'
            image.save(image_path + filename)

            return send_from_directory(image_path,
                                       filename,
                                       as_attachment=True)

        except Exception as e:
            print("error : %s" % e)
            return Response("fail", status=400)