MobileNet 0.25 模型压缩包内容解析

需积分: 13 1 下载量 18 浏览量 更新于2024-10-16 收藏 1.55MB ZIP 举报
资源摘要信息:"MobileNet是一种轻量级的深度神经网络架构,最初被设计用于移动和边缘设备上,以提高计算效率并减少模型大小。MobileNet的主要创新之一是使用深度可分离卷积来替代传统卷积,这种结构极大地减少了模型的复杂度和计算需求,同时尽量保持了准确度。MobileNet模型的版本很多,包括MobileNetv1、MobileNetv2、MobileNetv3等。v1版本首次引入深度可分离卷积的概念,而后续版本则在优化和改进方面做了大量工作。 在本资源中,文件名“mobilenet0.25_Final.zip”和“mobilenet0.25_Final.pth”暗示我们这是一个MobileNet模型的训练完成文件。具体地,这个文件可能是MobileNet模型的一个小型版本,其中“0.25”可能指的是宽度乘数(width multiplier),这是一个用于控制模型复杂度的超参数。宽度乘数越小,模型的宽度(即通道数)就越窄,导致模型变得更小,计算需求更低,同时准确度可能会有所下降。但是,这种调整通常用于那些对计算资源有限制的应用场景中。 文件中还提到了一个md5校验码“d***f997c63f79c7805b2cdab0”,这是一个标准的校验和,用于验证文件在传输或下载过程中是否保持完整,没有损坏或被篡改。用户在下载或获取该文件后,应该使用md5校验工具来比较自己计算得到的校验码和资源中提供的校验码是否一致,以此来确保文件的完整性和安全性。 从标签“mobilenet”可以得知,这个压缩包的内容与MobileNet模型相关。通常,使用pth作为文件扩展名表示该文件是一个训练好的模型参数文件,通常由PyTorch框架使用。因此,这个文件很可能是用PyTorch框架训练好的MobileNet模型的参数文件,可以用于部署和预测使用。 总结来说,该文件是针对特定应用场景优化的一个轻量级的MobileNet模型版本,可能适用于计算能力有限的设备,如手机、嵌入式设备等。它包含了模型的参数,且附带了校验码以确保文件的完整性和正确性。"

import cv2 import face_recognition import numpy as np from PIL import Image, ImageDraw,ImageFont video_capture = cv2.VideoCapture(r'C:/Users/ALIENWARE/123.mp4')#如果输入是(0)为摄像头输入 #现输入为MP4进行识别检测人脸 first_image = face_recognition.load_image_file("1.jpg") first_face_encoding = face_recognition.face_encodings(first_image)[0] Second_image = face_recognition.load_image_file("2.jpg") Second_face_encoding = face_recognition.face_encodings(Second_image)[0] third_image = face_recognition.load_image_file("3.jpg") third_face_encoding = face_recognition.face_encodings(third_image)[0] inside_face_encodings = [first_face_encoding,Second_face_encoding,third_face_encoding] inside_face_names = ['A','B','C'] face_locations = [] face_encodings = [] face_names = [] process_this_frame = True while True: ret, frame = video_capture.read() small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25) rgb_small_frame = small_frame[:, :, ::-1] if process_this_frame: face_locations = face_recognition.face_locations(rgb_small_frame) face_encodings = face_recognition.face_encodings(rgb_small_frame, face_locations) face_names = [] for face_encoding in face_encodings: matches = face_recognition.compare_faces(inside_face_encodings, face_encoding) name = '未录入人脸' if True in matches: first_match_index = matches.index(True) name = inside_face_names[first_match_index] face_names.append(name) process_this_frame = not process_this_frame for (top, right, bottom, left), name in zip(face_locations, face_names): top *= 4 right *= 4 bottom *= 4 left *= 4 cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2) img_pil = Image.fromarray(frame) draw = ImageDraw.Draw(img_pil) fontStyle = ImageFont.truetype("C:/Windows/Fonts/simsun.ttc", 32, encoding="utf-8") draw.text((left + 6, bottom - 6), name, (0, 200, 0), font=fontStyle) frame = np.asarray(np.array(img_pil)) cv2.imshow('face_out', frame) if cv2.waitKey(1) & 0xFF == ord('q'): #退出需要按下Q键否则内核会崩溃 break video_capture.release() cv2.destroyAllWindows()

2023-06-07 上传