处理流程:上传图片——分析图片获取密文——解码密文获得特征点——处理特征点获得值和结果——大模型进一步处理
由于模型部分由另一个同学负责编写 本篇文章不含此方面。
result( )
获取分析结果密文
def result():
username = session.get('username')
user = models.User.query.filter_by(username=username).first()
if user:
stageid1 = user.stageid
print(stageid1)
json_url = ''
token = tokens
data2 = {"stageId": stageid1}
headers1 = {
'Authorization': token}
response = requests.post(json_url, json=data2, headers=headers1)
if response.status_code == 200:
print(response.json())
jsonlist = response.json()
data = jsonlist["data"]
print(data)
return data
submit( )
提交file 提交头侧分析
def submit():
username = session.get('username')
user = models.User.query.filter_by(username=username).first()
if user:
stageid1 = user.stageid
print(stageid1)
json_url = ''
token = tokens
data2 = {"stageId": stageid1,
"typeList": ["ceph_locate"]}
headers1 = {
'Authorization': token}
response = requests.post(json_url, json=data2, headers=headers1)
if response.status_code == 200:
print(response.json())
return make_response(response.json())
open( )
利用test.py来解密 返回可以下载的http 得到json
def open1():
submit()
test = result()
userid = ''
print(generate_key(userid))
jsonlist = json.loads(decrypt(test, userid))
print(jsonlist)
url2 = jsonlist["point_json"]
# facial_landmarks_det_json
url = '/' + url2
return url
download_json1( )
下载json至指定的位置
def download_json1():
url = open1()
try:
# 发送 HTTP GET 请求获取 JSON 数据
response = requests.get(url)
response.raise_for_status() # 检查请求是否成功
# 将响应内容保存到本地文件
with open(new_save_path, 'wb') as file:
file.write(response.content)
print(f"JSON 文件已成功下载并保存到 {new_save_path}")
except requests.exceptions.RequestException as e:
print(f"请求失败: {e}")
except IOError as e:
print(f"文件保存失败: {e}")
getresult( )
根据指定文件名,读取json,并用beside.py对数据进行处理(北大分析法)
@app.route('/getresult', methods=['POST'])
def get():
ceph_analysis_methods = {
'beida': {
'name': '北大分析法',
'items': [
'SNA_id', 'SNB_id', 'ANB_id', 'FH_NPo_id', 'NA_APo_id',
'FH_MP_id', 'SGn_FH_id', 'SN_MP_id', 'Po_NB_id', 'U1_NA_id',
'dU1_NA_id', 'L1_NB_id', 'dL1_NB_id', 'U1_SN_id', 'L1_MP_id',
'U1_L1_id'
]
}
}
download_json()
with open(new_save_path, 'r') as f:
data = json.load(f)
parsed_data = parse_ceph_array_to_xy(data)
method = 'beida'
ruler = parsed_data["rulerLength"]
points = parsed_data["points"]
analysis_results = analyze_points(points, ruler, method, ceph_analysis_methods)
# 输出结果
total_list1=[]
for result in analysis_results:
cur_list1=[]
cur_list1.append(result['item'])
cur_list1.append(result['ref'])
cur_list1.append(result['actual'])
cur_list1.append(result['mark'])
cur_list1.append(result['bias'])
cur_list1.append(result['report'])
total_list1.append(cur_list1)
res = {
'code': 0,
'data': total_list1,
'msg': "分析成功"
}
return res
分析结果:
前端得到的数据
大模型返回: