人脸识别与大模型问答

This commit is contained in:
jiang 2024-08-27 14:20:50 +08:00
parent 2dded72955
commit 0ad768c81f
2 changed files with 13 additions and 5 deletions

View File

@ -60,10 +60,10 @@ import faceListShowPic from "@/views/updateFace/faceListShowPic.vue";
const validationRules = {
name: [
{required: true, message: '人员名称不能为空', trigger: 'blur'},
{min: 2, max: 20, message: '用户名称长度必须介于 2 和 10 之间', trigger: 'blur'},
{min: 2, max: 15, message: '用户名称长度必须介于 2 和 15 之间', trigger: 'blur'},
{
validator: (rule, value, callback) => {
const chineseNamePattern = /^[\u4e00-\u9fa5]{2,10}$/;
const chineseNamePattern = /^[\u4e00-\u9fa5·]{2,15}$/
if (!chineseNamePattern.test(value)) {
callback(new Error('姓名只能包含中文字符'));
} else {

View File

@ -111,9 +111,13 @@ export default {
},
methods: {
recognition(file) {
this.faceUrl = '';
this.name = '';
this.sex = '';
let formData = new FormData();
formData.append('file', file);
recognition(formData).then(res => {
console.log(res)
if (res.code == 200) {
let data = res.data;
this.faceUrl = data.faceAddress;
@ -121,9 +125,6 @@ export default {
this.sex = data.sex;
this.$message.success(res.msg)
} else {
this.faceUrl = '';
this.name = '';
this.sex = '';
this.$message.error(res.msg)
}
faceListResultCount.methods.getListFaceResult();
@ -143,6 +144,13 @@ export default {
handleFileChange(event) {
const file = event.target.files[0];
if (file) {
const maxSizeInMB = 20; // MB
const maxSizeInBytes = maxSizeInMB * 1024 * 1024;
if (file.size > maxSizeInBytes) {
this.$message.error(`文件大小不能超过 ${maxSizeInMB} MB`);
return;
}
this.imageUrl = URL.createObjectURL(file);
this.recognition(file)
}