Ejemplo n.º 1
0
def muti_attr(image):
    out = benchi_detect(image)
    label_dict = {}
    lis = []
    for i in range(len(out)):
        #根据置信度限定不符合要求的attr。
        #========my_setting==============
        if out[i, 2] > 0.5:
            label = int(out[i,1])
            lis.append(label)
        
    myset = sorted(set(lis))
    
    for key in myset:
        if key == 1:
            label_dict["hat"] = "Yes"
        elif key == 2:
            label_dict["hat"] = "No"
        elif key == 3:
            label_dict["coat"] = "Yes"
        elif key == 4:
            label_dict["coat"] = "No"
        elif key == 5:
            label_dict["gloves"] = "Yes"
        elif key == 6:
            label_dict["gloves"] = "No"
        elif key == 7:
            label_dict["shoes"] = "Yes"
        elif key == 8:
            label_dict["shoes"] = "No"
    return label_dict
Ejemplo n.º 2
0
def muti_attr(image):
    out = benchi_detect(image)
    label_dict = {}
    lis = []
    face_location = []
    label_dict["face"] = "Unknown"
    for i in range(len(out)):
        #根据置信度限定不符合要求的attr。
        #========my_setting==============
        control = True  #only once face detection.
        if out[i, 2] > 0.5:
            label = int(out[i, 1])
            lis.append(label)
            if label == 2 and control:
                # print("-------------->", out[i])
                clip_face_img = face_img(image, out[i])

                #保存人脸
                # save_file = "face_dlib/face_image"
                # cv2.imwrite(save_file+"/_{}.jpg".format(int(time.time())), clip_face_img)

                face_result = once_detect(clip_face_img)
                if face_result:
                    label_dict["face"] = face_result[0]
                    control = False

    myset = sorted(set(lis))
    for key in myset:
        if key == 1:
            label_dict["hat"] = 1
        elif key == 2:
            label_dict["hat"] = 0
        elif key == 3:
            label_dict["coat"] = 1
        elif key == 4:
            label_dict["coat"] = 0
        elif key == 5:
            label_dict["gloves"] = 1
        elif key == 6:
            label_dict["gloves"] = 0
        elif key == 7:
            label_dict["shoes"] = 0
        elif key == 8:
            label_dict["shoes"] = 0

    return label_dict