コード例 #1
0
ファイル: test.py プロジェクト: hanezu/GANimation
    def _img_morph(self, img, expresion):
        bbs = face_recognition.face_locations(img)
        if len(bbs) > 0:
            y, right, bottom, x = bbs[0]
            bb = x, y, (right - x), (bottom - y)
            face = face_utils.crop_face_with_bb(img, bb)
            face = face_utils.resize_face(face)
        else:
            face = face_utils.resize_face(img)

        morphed_face = self._morph_face(face, expresion)

        return morphed_face
コード例 #2
0
ファイル: test.py プロジェクト: iGuaZi/GANimation
    def _img_morph(self, img, expresion):
        bbs = face_recognition.face_locations(img)
        if len(bbs) > 0:
            y, right, bottom, x = bbs[0]
            bb = x, y, (right - x), (bottom - y)
            face = face_utils.crop_face_with_bb(img, bb)
            face = face_utils.resize_face(face)
        else:
            face = face_utils.resize_face(img)

        morphed_face = self._morph_face(face, expresion)

        return morphed_face
コード例 #3
0
    def modify_face(self, img, expresion):
        # get face part
        bbs = face_recognition.face_locations(img)
        if len(bbs) > 0:
            y, right, bottom, x = bbs[0]
            bb = x, y, (right - x), (bottom - y)
            face = face_utils.crop_face_with_bb(img, bb)
            face = face_utils.resize_face(face)
        else:
            face = face_utils.resize_face(img)  # 128x128

        # modify face by expression
        morphed_face = self._morph_face(face, expresion)

        return morphed_face
コード例 #4
0
    def _img_morph(self, img, expression):
        bbs = face_recognition.face_locations(img)
        if len(bbs) > 0:
            y, right, bottom, x = bbs[0]
            bb = x, y, (right - x), (bottom - y)
            face = face_utils.crop_face_with_bb(img, bb)
            face = face_utils.resize_face(face)
        else:
            face = face_utils.resize_face(img)

        img_cond = self.find_disriminator_regression(face)
        print('from discriminator: ', img_cond)

        morphed_face = self._morph_face(face, expression, img_cond)

        return morphed_face
コード例 #5
0
 def _overlay_fake_img(self, img, face, bbs):
     overlay_copy = img
     if len(bbs) > 0:
         y, right, bottom, x = bbs[0]
         ratio = ((bottom - y) / face.shape[0], (right - x) / face.shape[0])
         face = face_utils.resize_face(face, (int(face.shape[0]*ratio[0]), int(face.shape[1]*ratio[1])))
         #print(y, right, bottom, x)
         #print(overlay_copy.shape)
         overlay_copy[y:y + face.shape[0], x:x +face.shape[1]] = face
     return overlay_copy