flask 和fastdeploy 快速部署 yolov3

服务端

from flask import Flask,request,render_template
from flask import  session,redirect,jsonify
import cv2
import numpy as np
import base64
import os
import fastdeploy as fd
import datetime,time

app=Flask(__name__)

from logging import config,getLogger
logger=getLogger('WebAPI')

def get_image_data():
    """
    将客户端传入的图片数据(base64字符串格式)转成numpy.ndarray格式
    """
    params = request.json
    if not params["images"]: # 列表为空
        return "No image received, please check"
    img = params["images"]
    try:
        img = base64.b64decode(img)
        img = np.frombuffer(img, np.uint8)
        img = cv2.imdecode(img, cv2.IMREAD_COLOR)
    except Exception as e:
        print(e)
        return "Not valid image type!"

    return img

def cv2_to_base64(image, img_type=".bmp"):
    """
    将cv2 numpy ndarray格式的图片数据转成s

你可能感兴趣的:(目标检测,深度学习,1024程序员节)