crop_face #1

Merged
s444409 merged 4 commits from crop_face into main 2023-01-29 21:15:22 +01:00
4 changed files with 57672 additions and 3 deletions

BIN
UAM-Andre.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

11
main.py
View File

@ -14,8 +14,13 @@ def load_source(filename: str) -> np.ndarray:
def find_and_crop_face(data: np.ndarray) -> np.ndarray: def find_and_crop_face(data: np.ndarray) -> np.ndarray:
# TODO data_gray = cv2.cvtColor(data, cv2.COLOR_BGR2GRAY)
return data face_cascade = cv2.CascadeClassifier('haarcascades/haarcascade_frontalface_default.xml')
face = face_cascade.detectMultiScale(data_gray, 1.3, 4)
face = max(face, key=len)
s444409 marked this conversation as resolved
Review

x, y, w, h = face

`x, y, w, h = face`
x, y, w, h = face
face = data[y:y + h, x:x + w]
return face
def compare_with_anime_characters(data: np.ndarray) -> int: def compare_with_anime_characters(data: np.ndarray) -> int:
@ -23,7 +28,7 @@ def compare_with_anime_characters(data: np.ndarray) -> int:
return 1 return 1
def transfer_to_anime(ima: np.ndarray): def transfer_to_anime(img: np.ndarray):
algo = Cartoonizer(dataroot='damo/cv_unet_person-image-cartoon_compound-models') algo = Cartoonizer(dataroot='damo/cv_unet_person-image-cartoon_compound-models')
return algo.cartoonize(img) return algo.cartoonize(img)