1 Star 0 Fork 0

Nuyoah/scaning_block

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main_v3.py 1.36 KB
一键复制 编辑 原始数据 按行查看 历史
Nuyoah 提交于 2024-07-05 19:22 . feat:增加批量检测识别结果参数
from flask import Flask, request, jsonify
#import test_similarity as test
#import tc_rgb_test_similarity_v1 as test
#import tc_rgb_test_similarity as test
#import test_similarity as test
import polyblock_test as test
import os
import json
app = Flask(__name__)
@app.route('/upload_file', methods=['POST'])
def upload_file():
if 'file' not in request.files:
return jsonify({'error': 'No file part'})
file = request.files['file']
if file.filename == '':
return jsonify({'error': 'No selected file'})
print(file.filename)
# 保存上传的文件至服务器
file.save('uploads/' + file.filename)
# 相似值
try:
value = test.similarity_localImage('uploads/' + file.filename)
print(value)
except Exception as e:
value = -2000
print(e)
for item in value:
item_dict = json.loads(item)
filename = str(item_dict["name"]) + ".txt"
# Write the "value" field to the file
with open(filename, 'a') as f:
f.write(str(item_dict['value'])+ "\n") # Write the dictionary entry as a string to the file
# 返回值
return_data = jsonify({
'code': 200,
'value': value
})
# os.remove('uploads/' + file.filename)
return return_data
# http服务器
if __name__ == '__main__':
app.run(host="0.0.0.0", port=8887, threaded=True)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xiaoshengdi/scaning_block.git
git@gitee.com:xiaoshengdi/scaning_block.git
xiaoshengdi
scaning_block
scaning_block
master

搜索帮助