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

一个新网站做多久才有流量转化2023最建议买三款手机

一个新网站做多久才有流量转化,2023最建议买三款手机,惠州网站关键字优化,网页版传奇手游排行榜人脸匹配 导入所需的库加载dlib的人脸识别模型和面部检测器读取图片并转换为灰度图比较两张人脸选择图片并显示结果比较图片创建GUI界面运行GUI主循环运行显示全部代码 导入所需的库 cv2#xff1a;OpenCV库#xff0c;用于图像处理。 dlib#xff1a;一个机器学习库#x… 人脸匹配 导入所需的库加载dlib的人脸识别模型和面部检测器读取图片并转换为灰度图比较两张人脸选择图片并显示结果比较图片创建GUI界面运行GUI主循环运行显示全部代码 导入所需的库 cv2OpenCV库用于图像处理。 dlib一个机器学习库用于人脸检测和特征点预测。 numpy用于数值计算的库。 PIL和ImageTk用于处理图像和创建Tkinter兼容的图像对象。 filedialogTkinter的一个模块用于打开文件对话框。 Tk、Label、Button、CanvasTkinter库的组件用于创建GUI。 import cv2 import dlib import numpy as np from PIL import Image, ImageTk from tkinter import filedialog from tkinter import Tk, Label, Button, Canvas加载dlib的人脸识别模型和面部检测器 使用dlib.get_frontal_face_detector()加载面部检测器。 使用dlib.shape_predictor()加载面部特征点预测模型。 使用dlib.face_recognition_model_v1()加载人脸识别模型。 detector dlib.get_frontal_face_detector() predictor dlib.shape_predictor(shape_predictor_68_face_landmarks.dat) face_rec dlib.face_recognition_model_v1(dlib_face_recognition_resnet_model_v1.dat)读取图片并转换为灰度图 读取图片并转换为灰度图。 使用面部检测器检测图像中的面部。 如果检测到多张或没有脸则抛出异常。 提取面部特征点并计算人脸编码。 def get_face_encoding(image_path):img cv2.imread(image_path)gray cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)faces detector(gray)if len(faces) ! 1:raise ValueError(图片中检测到多张或没有脸)face faces[0]shape predictor(gray, face)face_encoding np.array(face_rec.compute_face_descriptor(img, shape))return face_encoding比较两张人脸 比较两个人脸编码。 计算两个编码之间的欧氏距离。 如果距离小于0.6则认为它们是同一个人脸。 def compare_faces(face1, face2):distance np.linalg.norm(face1 - face2)if distance 0.6:return 相同人脸else:return 不同人脸选择图片并显示结果 定义select_image1、select_image2和select_image3函数。 打开文件对话框让用户选择图片。 将选择的图片显示在相应的画布上。 def select_image1():global image1_path, image1image1_path filedialog.askopenfilename()image1 Image.open(image1_path)image1 image1.resize((300, 300), Image.LANCZOS) # 使用Image.LANCZOS替换ANTIALIASphoto1 ImageTk.PhotoImage(image1)canvas1.create_image(0, 0, anchornw, imagephoto1)canvas1.image photo1def select_image2():global image2_path, image2image2_path filedialog.askopenfilename()image2 Image.open(image2_path)image2 image2.resize((300, 300), Image.LANCZOS) # 使用Image.LANCZOS替换ANTIALIASphoto2 ImageTk.PhotoImage(image2)canvas2.create_image(0, 0, anchornw, imagephoto2)canvas2.image photo2def select_image3():global image3_path, image3image3_path filedialog.askopenfilename()image3 Image.open(image3_path)image3 image3.resize((300, 300), Image.LANCZOS) # 使用Image.LANCZOS替换ANTIALIASphoto3 ImageTk.PhotoImage(image3)canvas3.create_image(0, 0, anchornw, imagephoto3)canvas3.image photo3比较图片 定义compare_images1和compare_images2函数 获取两个人脸编码并进行对比。 显示对比结果。 def compare_images1():try:face1 get_face_encoding(image1_path)face2 get_face_encoding(image2_path)result1 compare_faces(face1, face2)result_label1.config(textresult1)except Exception as e:result_label1.config(text发生错误: str(e))def compare_images2():try:face2 get_face_encoding(image2_path)face3 get_face_encoding(image3_path)result2 compare_faces(face2, face3)result_label2.config(textresult2)except Exception as e:result_label2.config(text发生错误: str(e))创建GUI界面 设置窗口标题和大小。 创建画布来显示图片。 创建标签来显示对比结果。 创建按钮让用户选择图片和进行对比。 # 创建GUI root Tk() root.title(人脸对比) root.geometry(1000x620)# 创建画布来显示图片 canvas1 Canvas(root, width300, height300, bgwhite) canvas1.pack(sideleft, padx10, pady10) canvas2 Canvas(root, width300, height300, bgwhite) canvas2.pack(sideleft, padx10, pady10) canvas3 Canvas(root, width300, height300, bgwhite) canvas3.pack(sideleft, padx10, pady10)# 创建标签来显示结果 result_label1 Label(root, text) result_label1.place(x300, y120) result_label2 Label(root, text) result_label2.place(x640, y120)# 创建按钮来选择图片 button1 Button(root, text选择第一张图片, commandselect_image1) button1.place(x100, y50) button2 Button(root, text选择第二张图片, commandselect_image2) button2.place(x450, y50) button3 Button(root, text选择第三张图片, commandselect_image3) button3.place(x800, y50)# 创建按钮来对比图片 compare_button1 Button(root, text对比图像12, commandcompare_images1) compare_button1.place(x300, y80) compare_button2 Button(root, text对比图像23, commandcompare_images2) compare_button2.place(x640, y80)运行GUI主循环 root.mainloop()运行显示 全部代码 import cv2 import dlib import numpy as np from PIL import Image, ImageTk from tkinter import filedialog from tkinter import Tk, Label, Button, Canvas# 加载dlib的人脸识别模型和面部检测器 #使用dlib.get_frontal_face_detector()加载面部检测器 # 使用dlib.shape_predictor()加载面部特征点预测模型 # 使用dlib.face_recognition_model_v1()加载人脸识别模型 detector dlib.get_frontal_face_detector() predictor dlib.shape_predictor(shape_predictor_68_face_landmarks.dat) face_rec dlib.face_recognition_model_v1(dlib_face_recognition_resnet_model_v1.dat)# 读取图片并转换为灰度图 def get_face_encoding(image_path):img cv2.imread(image_path)gray cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)faces detector(gray)if len(faces) ! 1:raise ValueError(图片中检测到多张或没有脸)face faces[0]shape predictor(gray, face)face_encoding np.array(face_rec.compute_face_descriptor(img, shape))return face_encoding# 比较两张人脸 def compare_faces(face1, face2):distance np.linalg.norm(face1 - face2)if distance 0.6:return 相同人脸else:return 不同人脸# 选择图片并显示结果 def select_image1():global image1_path, image1image1_path filedialog.askopenfilename()image1 Image.open(image1_path)image1 image1.resize((300, 300), Image.LANCZOS) # 使用Image.LANCZOS替换ANTIALIASphoto1 ImageTk.PhotoImage(image1)canvas1.create_image(0, 0, anchornw, imagephoto1)canvas1.image photo1def select_image2():global image2_path, image2image2_path filedialog.askopenfilename()image2 Image.open(image2_path)image2 image2.resize((300, 300), Image.LANCZOS) # 使用Image.LANCZOS替换ANTIALIASphoto2 ImageTk.PhotoImage(image2)canvas2.create_image(0, 0, anchornw, imagephoto2)canvas2.image photo2def select_image3():global image3_path, image3image3_path filedialog.askopenfilename()image3 Image.open(image3_path)image3 image3.resize((300, 300), Image.LANCZOS) # 使用Image.LANCZOS替换ANTIALIASphoto3 ImageTk.PhotoImage(image3)canvas3.create_image(0, 0, anchornw, imagephoto3)canvas3.image photo3def compare_images1():try:face1 get_face_encoding(image1_path)face2 get_face_encoding(image2_path)result1 compare_faces(face1, face2)result_label1.config(textresult1)except Exception as e:result_label1.config(text发生错误: str(e))def compare_images2():try:face2 get_face_encoding(image2_path)face3 get_face_encoding(image3_path)result2 compare_faces(face2, face3)result_label2.config(textresult2)except Exception as e:result_label2.config(text发生错误: str(e))# 创建GUI root Tk() root.title(人脸对比) root.geometry(1000x620)# 创建画布来显示图片 canvas1 Canvas(root, width300, height300, bgwhite) canvas1.pack(sideleft, padx10, pady10) canvas2 Canvas(root, width300, height300, bgwhite) canvas2.pack(sideleft, padx10, pady10) canvas3 Canvas(root, width300, height300, bgwhite) canvas3.pack(sideleft, padx10, pady10)# 创建标签来显示结果 result_label1 Label(root, text) result_label1.place(x300, y120) result_label2 Label(root, text) result_label2.place(x640, y120)# 创建按钮来选择图片 button1 Button(root, text选择第一张图片, commandselect_image1) button1.place(x100, y50) button2 Button(root, text选择第二张图片, commandselect_image2) button2.place(x450, y50) button3 Button(root, text选择第三张图片, commandselect_image3) button3.place(x800, y50)# 创建按钮来对比图片 compare_button1 Button(root, text对比图像12, commandcompare_images1) compare_button1.place(x300, y80) compare_button2 Button(root, text对比图像23, commandcompare_images2) compare_button2.place(x640, y80)root.mainloop()
http://www.hkea.cn/news/14467385/

相关文章:

  • 湖北钟祥建设局网站衡水电商网站建设价格
  • 模型网站大全免费wordpress 留言功能
  • 前端怎么做网站做网站的文章
  • 启东市住房建设局网站南京医院手机网站建设
  • 网站换模板对seo元氏网站制作
  • 汕头站扩建工程网站推广优化建设
  • dw建设网站自媒体seo优化
  • 营销型网站有哪些建设流程网站建设应遵循哪几项原则
  • 我有网网站建设wordpress更新主题
  • 未明潮网站建设保密协议网站开发项目经理
  • 网站制作时间耒阳住房与建设局网站
  • 网站如何优化关键词老河口市建设局网站
  • 专做排名的网站wordpress cascade
  • 搭建网站程序广州网络推广引流
  • 开发网站的软件襄阳市住房和城乡建设局网站
  • 免费婚恋网站设计wordpress网站换字体颜色
  • 电子商务网站建设试卷与答案兰州网站设计哪个平台好
  • 网站图片上传不了是什么原因甘肃建网站
  • 网站建设及维护课件免费如何注册网站域名
  • 江苏建安建设有限公司网站重庆沙坪坝二手房出售信息
  • 扬州网站seo建立以()为特点
  • 网站页面策划模板下载建设银行住房公积金卡网站
  • 做网站的公司怎么赚钱吗阿里云网站实名认证
  • 重庆网站建设公司的网站营销型网站建设 合肥
  • 学校网站建设问卷调查每天自动更新的网站
  • php与mysql网站开发做网站前端用什么软件
  • 用手机怎样免费做网站营销型网站一般有哪些内容
  • 本地的丹阳网站建设成都互联网公司十强
  • 备份整个网站端午节ppt模板免费下载
  • 收录网站工具某网站开发工具和技术