본문 바로가기

프로젝트결과물

나만의 퍼스널컬러 찾기

youtu.be/U8byauK62dg

관련된 나의 포스팅:

얼굴인식 관련 포스팅 - studycodeihl.tistory.com/17?category=803319

딥러닝 관련 포스팅 - https://studycodeihl.tistory.com/10

웹 포트포워딩 관련 포스팅 - studycodeihl.tistory.com/15?category=806109

 

주요코드

def is_warm(lab, hsv):
    
    #h5 모델 불러오기
    model = load_model('warm_cool_.h5')
    
    
    #warm or cool
    Y_prediction = model.predict([[lab[0], lab[1], lab[2], 
                                    lab[3], lab[4], lab[5], 
                                    lab[6],lab[7], lab[8], 
                                    hsv[0], hsv[1], hsv[2], 
                                    hsv[3], hsv[4], hsv[5], 
                                    hsv[6], hsv[7], hsv[8]]])
    

    return np.argmax(Y_prediction)
def analysis(imgpath):
    #Detect face elemet
    df = DetectFace(imgpath)
    face = [df.left_cheek, df.right_cheek,
            df.left_eyebrow, df.right_eyebrow,
            df.left_eye, df.right_eye]

    #Get dominant Color
    temp = []
    clusters = 4
    for f in face:
        dc = DominantColors(f, clusters)
        face_part_color, _ = dc.getHistogram()
        temp.append(np.array(face_part_color[0]))
    cheek = np.mean([temp[0], temp[1]], axis=0)
    eyebrow = np.mean([temp[2], temp[3]], axis=0)
    eye = np.mean([temp[4], temp[5]], axis=0)

    Lab_b, hsv_s = [], []
    LabList, HsvList = [], []
    color = [cheek, eyebrow, eye]
    for i in range(3):
        rgb = sRGBColor(color[i][0], color[i][1], color[i][2], is_upscaled=True)
        lab = convert_color(rgb, LabColor, through_rgb_type=sRGBColor)
        hsv = convert_color(rgb, HSVColor, through_rgb_type=sRGBColor)
        LabList.extend([lab.lab_l, lab.lab_a, lab.lab_b])
        HsvList.extend([hsv.hsv_h, hsv.hsv_s, hsv.lab_v])

    #analysis personalcolor
    if(tone_analysis.is_warm(LabList, HsvList)):
        if(tone_analysis.is_spr(LabList, HsvList)):
            tone = '봄웜톤(spring)'
        else:
            tone = '가을웜톤(fall)'
    else:
        if(tone_analysis.is_smr(LabList, HsvList)):
            tone = '여름쿨톤(summer)'
        else:
            tone = '겨울쿨톤(winter)'
    # Print Result
    print('퍼스널 컬러는 {}입니다.'.format(tone))