wuhuikai / FaceSwap

Swap face between two photos.
725 stars 226 forks source link

TypeError: Invalid index type #33

Closed EricSyu2816 closed 3 years ago

EricSyu2816 commented 3 years ago

There is a error occour when I execute the command python main.py --src imgs/test6.jpg --dst imgs/test7.jpg --out results/output6_7.jpg --correct_color

How can I fix it? thanks!

EricSyu2816 commented 3 years ago

Traceback (most recent call last): File "main.py", line 25, in src_points, src_shape, src_face = select_face(src_img) File "D:\Deep fake\FaceSwap\face_detection.py", line 37, in select_face bbox = faces[idx] TypeError: Invalid index type

kehlerr commented 3 years ago

Probably there are no recognizible faces on photo

wuhuikai commented 3 years ago

Probably there are no recognizible faces on photo

I think so~

tisbuet commented 3 years ago

Use list(faces)[idx] instead of faces[idx]

2007anu commented 2 years ago

@kehlerr @tisbuet Index type error is still coming while executing below command:

python main.py --src imgs/test6.jpg --dst imgs/test7.jpg --out results/output6_7_2d.jpg --correct_color --warp_2d

Error:

TypeError Traceback (most recent call last) ~\Downloads\FaceSwap\main.py in () 23 24 # Select src face ---> 25 src_points, src_shape, src_face = select_face(src_img) 26 # Select dst face 27 dst_faceBoxes = select_all_faces(dst_img)

~\Downloads\FaceSwap\face_detection.py in select_face(im, r, choose) 35 36 if len(faces) == 1 or not choose: ---> 37 idx = np.argmax([(face.right() - face.left()) * (face.bottom() - face.top()) for face in faces]) 38 #print(idx) 39 bbox = list(faces)[idx]

TypeError: Invalid index type