当前位置: 首页 > news >正文

高性能网站建设指南 pdf东莞网站开发公司

高性能网站建设指南 pdf,东莞网站开发公司,iis7 伪静态 wordpress,如何制作网络先看结果 必须遥遥领先 所需准备 这里我调用了#xff1a; 人脸比对 API 文档 | 讯飞开放平台文档中心https://www.xfyun.cn/doc/face/xffaceComparisonRecg/API.html#%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E 代码里所涉及的APPID、APISecret、APIKey 皆从讯飞的控制台获取 人脸比对 API 文档 | 讯飞开放平台文档中心https://www.xfyun.cn/doc/face/xffaceComparisonRecg/API.html#%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E 代码里所涉及的APPID、APISecret、APIKey 皆从讯飞的控制台获取自己注册去讯飞开放平台-以语音交互为核心的人工智能开放平台申请即可。 话不多说上代码  代码实现  ##APPID、APISecret、APIKey一定要填写##import tkinter as tk from tkinter import filedialog from tkinter import Label from tkinter import ttk from PIL import Image, ImageTk import json import requests import base64 import hmac import hashlib from datetime import datetime from time import mktime from wsgiref.handlers import format_date_time from urllib.parse import urlencodeclass AssembleHeaderException(Exception):def __init__(self, msg):self.message msgclass Url:def __init__(this, host, path, schema):this.host hostthis.path paththis.schema schemadef sha256base64(data):sha256 hashlib.sha256()sha256.update(data)digest base64.b64encode(sha256.digest()).decode(encodingutf-8)return digestdef parse_url(request_url):stidx request_url.index(://)host request_url[stidx 3:]schema request_url[:stidx 3]edidx host.index(/)if edidx 0:raise AssembleHeaderException(invalid request url: request_url)path host[edidx:]host host[:edidx]u Url(host, path, schema)return udef assemble_ws_auth_url(request_url, methodGET, api_key, api_secret):u parse_url(request_url)host u.hostpath u.pathnow datetime.now()date format_date_time(mktime(now.timetuple()))signature_origin host: {}\ndate: {}\n{} {} HTTP/1.1.format(host, date, method, path)signature_sha hmac.new(api_secret.encode(utf-8), signature_origin.encode(utf-8),digestmodhashlib.sha256).digest()signature_sha base64.b64encode(signature_sha).decode(encodingutf-8)authorization_origin api_key\%s\, algorithm\%s\, headers\%s\, signature\%s\ % (api_key, hmac-sha256, host date request-line, signature_sha)authorization base64.b64encode(authorization_origin.encode(utf-8)).decode(encodingutf-8)values {host: host,date: date,authorization: authorization}return request_url ? urlencode(values)def gen_body(appid, img1_path, img2_path, server_id):with open(img1_path, rb) as f:img1_data f.read()with open(img2_path, rb) as f:img2_data f.read()body {header: {app_id: appid,status: 3},parameter: {server_id: {service_kind: face_compare,face_compare_result: {encoding: utf8,compress: raw,format: json}}},payload: {input1: {encoding: jpg,status: 3,image: str(base64.b64encode(img1_data), utf-8)},input2: {encoding: jpg,status: 3,image: str(base64.b64encode(img2_data), utf-8)}}}return json.dumps(body)def run(appid, apikey, apisecret, img1_path, img2_path, server_ids67c9c78c):url http://api.xf-yun.com/v1/private/{}.format(server_id)request_url assemble_ws_auth_url(url, POST, apikey, apisecret)headers {content-type: application/json, host: api.xf-yun.com, app_id: appid}response requests.post(request_url, datagen_body(appid, img1_path, img2_path, server_id), headersheaders)resp_data json.loads(response.content.decode(utf-8))result base64.b64decode(resp_data[payload][face_compare_result][text]).decode()return resultdef browse_file(entry_widget, image_label, img_num):file_path filedialog.askopenfilename()if file_path:entry_widget.delete(0, tk.END)entry_widget.insert(0, file_path)load_and_display_image(file_path, image_label, img_num)def load_and_display_image(file_path, image_label, image_num):try:image Image.open(file_path)image image.resize((200, 200))photo ImageTk.PhotoImage(image)image_label.config(imagephoto)image_label.image photoif image_num 1:global img1_dataimg1_data imageelif image_num 2:global img2_dataimg2_data imageexcept Exception as e:result_label.config(text加载图片出错请检查文件格式)def compare_faces():if img1_data not in globals() or img2_data not in globals():result_label.config(text请选择两张图片进行比对)returntry:img1_path img1.jpgimg2_path img2.jpgimg1_data.save(img1_path)img2_data.save(img2_path)result run(appid,#自行申请填写apisecret,#自行申请填写apikey,#自行申请填写img1_pathimg1_path,img2_pathimg2_path)score float(json.loads(result)[score])if score 0.67:result_label.config(textf这两张图片是同一个人相似度{score:.2f})else:result_label.config(textf这两张图片不是同一个人相似度{score:.2f})except Exception as e:result_label.config(text比对出错请检查图片和配置)root tk.Tk() root.title(人脸比对)# 设置样式主题 style ttk.Style() style.configure(TButton, font(Helvetica, 12)) style.configure(TLabel, font(Helvetica, 14))frame ttk.LabelFrame(root, text选择图片) frame.grid(row0, column0, columnspan2, padx10, pady10, stickyew) entry1 tk.Entry(frame, width50) entry2 tk.Entry(frame, width50) entry1.grid(row0, column0, padx10, pady10) entry2.grid(row1, column0, padx10, pady10)separator ttk.Separator(root, orienthorizontal) separator.grid(row1, column0, columnspan2, stickyew)button1 ttk.Button(root, text选择图片1, commandlambda: browse_file(entry1, img_label1, 1)) button2 ttk.Button(root, text选择图片2, commandlambda: browse_file(entry2, img_label2, 2)) button1.grid(row2, column0, padx10, pady10) button2.grid(row2, column1, padx10, pady10)compare_button ttk.Button(root, text比对图片, commandcompare_faces) compare_button.grid(row3, column0, columnspan2, pady20)result_label Label(root, text, font(Helvetica, 14)) result_label.grid(row4, column0, columnspan2, padx10, pady10)img_label1 tk.Label(root) img_label1.grid(row5, column0, padx10, pady10) img_label2 tk.Label(root) img_label2.grid(row5, column1, padx10, pady10)root.mainloop()为了美观并优化弹窗的布局使用了ttk.LabelFrame来创建一个带有标题的框架用于容纳选择图片的部件。还在界面中添加了一个水平分隔符ttk.Separator以提高界面的可读性。 官方代码里图片路径需要自行填写改进后则使得可以从本地选择需要对比图片。
http://www.pierceye.com/news/921111/

相关文章:

  • 传媒公司注册经营范围有哪些北京百度seo排名点击器
  • 什么是cms网站系统做响应式网站怎么设计
  • wordpress多城市子站在线培训网站
  • 企业网站服务门户网站搬家怎么做
  • 免费浏览外国网站的软件防止访问网站文件夹
  • 长沙县政务网站公司介绍怎么写范本
  • 免费网站建设方案优化seo整体优化
  • 境外公司在国内建网站微信小程序登录平台
  • 手机网站页面模板企业网站建设相关书籍在线阅读
  • 服装网站建设内容asp网站服务建设论文
  • 开封 网站建设 网络推广如何用xshell安装wordpress
  • 河北建设工程信息网站银行外包不是人干的
  • 郑州免费做网站的襄阳品牌网站建设
  • 爱网站站长工具android软件开发下载
  • 网站被入侵宁波妇科医生推荐
  • 移动网站建设学习新能源汽车价格表2021
  • 如何做视频会员网站工商注册公司需要提供的资料
  • 网站做多久能盈利网站设计定做
  • 微信网站后台功能哪里买域名便宜
  • 合肥重点工程建设局密云seo排名优化培训
  • 二学一做网站福建建设资格执业注册管理中心网站
  • vps 网站上传做网站费用需要分摊吗
  • 建网站 考虑oou淘宝客图片wordpress模板
  • 玩具网站开发背景小说网站开发文档
  • 遵义网站设计公司制作网站需要
  • 做广告公司网站建设价格成都seo招聘
  • 网站建设与规划试卷友联互换
  • 宠物网站建设费用天元建设集团有限公司是国企吗
  • 南宁在百度上建网站网站设计怎么做链接
  • 多多进宝怎么做自己网站沈阳正规的男科医院