代码拉取完成,页面将自动刷新
import os,PIL
import numpy as np
from PyQt5.QtWidgets import QFileDialog,QMessageBox
from src.utils.GlobalVariable import models
def get_img_path(parent=None):
path, _ = QFileDialog.getOpenFileName(
parent, "选择文件", "c:\\", "Image files(*.jpg *.gif *.png)")
if path == '':
return False
elif os.path.getsize(path) > 1024000 :
QMessageBox.critical(parent, 'Wrong', '文件应小于10mb')
return False
data = open(path,"rb").read(32)
if not (data[6:10] in (b'JFIF',b'Exif')):#检查文件类型是否属于jpg文件
QMessageBox.critical(parent, 'Wrong', '文件非图片文件')
return False
rgbImage = PIL.Image.open(path)
rgbImage = rgbImage .convert("RGB")
rgbImage = np.array(rgbImage )
faces = models.detector(rgbImage)
if len(faces) == 1:
return path
else:
QMessageBox.critical(parent, 'Wrong', '文件不存在人脸或多个人脸')
return False
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。