Python Flask搭建yolov3目標檢測系統(tǒng)詳解流程
更新時間:2021年11月06日 10:13:13 作者:mind_programmonkey
YOLOv3沒有太多的創(chuàng)新,主要是借鑒一些好的方案融合到YOLO里面。不過效果還是不錯的,在保持速度優(yōu)勢的前提下,提升了預測精度,尤其是加強了對小物體的識別能力
【人工智能項目】Python Flask搭建yolov3目標檢測系統(tǒng)

后端代碼
from flask import Flask, request, jsonify
from PIL import Image
import numpy as np
import base64
import io
import os
from backend.tf_inference import load_model, inference
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
sess, detection_graph = load_model()
app = Flask(__name__)
@app.route('/api/', methods=["POST"])
def main_interface():
response = request.get_json()
data_str = response['image']
point = data_str.find(',')
base64_str = data_str[point:] # remove unused part like this: "data:image/jpeg;base64,"
image = base64.b64decode(base64_str)
img = Image.open(io.BytesIO(image))
if(img.mode!='RGB'):
img = img.convert("RGB")
# convert to numpy array.
img_arr = np.array(img)
# do object detection in inference function.
results = inference(sess, detection_graph, img_arr, conf_thresh=0.7)
print(results)
return jsonify(results)
@app.after_request
def add_headers(response):
response.headers.add('Access-Control-Allow-Origin', '*')
response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
return response
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
展示部分
python -m http.server

python app.py

前端展示部分

到此這篇關于Python Flask搭建yolov3目標檢測系統(tǒng)詳解流程的文章就介紹到這了,更多相關Python 目標檢測系統(tǒng)內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
pyinstaller打包exe程序的步驟和添加依賴文件的實現(xiàn)
這篇文章主要介紹了pyinstaller打包exe程序的步驟和添加依賴文件的實現(xiàn)方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-02-02
Python實現(xiàn)Smtplib發(fā)送帶有各種附件的郵件實例
本篇文章主要介紹了Python實現(xiàn)Smtplib發(fā)送帶有各種附件的郵件實例,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-06-06

