crop_face #1
BIN
UAM-Andre.jpg
Normal file
BIN
UAM-Andre.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 67 KiB |
24350
haarcascades/haarcascade_frontalface_alt.xml
Normal file
24350
haarcascades/haarcascade_frontalface_alt.xml
Normal file
File diff suppressed because it is too large
Load Diff
33314
haarcascades/haarcascade_frontalface_default.xml
Normal file
33314
haarcascades/haarcascade_frontalface_default.xml
Normal file
File diff suppressed because it is too large
Load Diff
11
main.py
11
main.py
@ -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
|
|||||||
|
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)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user
x, y, w, h = face