Python Flask搭建yolov3目标检测系统详解流程
作者:mind_programmonkey 时间:2023-07-07 12:40:05
【人工智能项目】Python Flask搭建yolov3目标检测系统
后端代码
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
前端展示部分
来源:https://blog.csdn.net/Mind_programmonkey/article/details/121051114
标签:Python,目标检测系统,Flask,yolov3
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python3实现飞机大战
2023-03-03 00:36:18
![](https://img.aspxhome.com/file/2023/8/87588_0s.jpg)
python根据txt文本批量创建文件夹
2021-12-18 21:24:52
![](https://img.aspxhome.com/file/2023/2/84962_0s.png)
js常用排序实现代码
2023-08-30 08:50:24
Python自动扫描出微信不是好友名单的方法
2023-03-14 09:25:44
![](https://img.aspxhome.com/file/2023/7/88977_0s.png)
python子线程如何有序执行
2022-03-14 01:08:54
MySQL case when使用方法实例解析
2024-01-29 03:15:55
![](https://img.aspxhome.com/file/2023/8/103568_0s.png)
用Python 执行cmd命令
2022-06-08 15:29:17
解读! Python在人工智能中的作用
2022-02-20 20:51:54
Python+tkinter制作经典登录界面和点击事件
2022-12-04 03:32:25
![](https://img.aspxhome.com/file/2023/8/76768_0s.png)
Python编程使用有限状态机识别地址有效性
2023-09-03 00:14:56
![](https://img.aspxhome.com/file/2023/2/133892_0s.jpg)
实例简析XPath串函数和XSLT
2008-09-04 14:16:00
在自动化中用python实现键盘操作的方法详解
2021-02-04 00:23:48
Python常用数据库接口sqlite3和MySQLdb学习指南
2024-01-16 00:53:56
用python实现域名资产监控的详细步骤
2021-12-05 07:52:49
![](https://img.aspxhome.com/file/2023/8/69538_0s.png)
selenium+python自动化78-autoit参数化与批量上传功能的实现
2023-11-02 01:24:57
![](https://img.aspxhome.com/file/2023/3/104953_0s.png)
Python 删除List元素的三种方法remove、pop、del
2021-06-14 20:58:52
Python爬虫设置代理IP的方法(爬虫技巧)
2023-08-08 22:05:36
Python如何加载模型并查看网络
2021-11-01 15:53:22
![](https://img.aspxhome.com/file/2023/3/115123_0s.png)
vue实现移动端图片裁剪上传功能
2024-05-10 14:15:04
![](https://img.aspxhome.com/file/2023/8/126538_0s.jpg)
基于Python的身份证号码自动生成程序
2022-11-29 02:00:33
![](https://img.aspxhome.com/file/2023/3/96993_0s.jpg)