You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Below is the code I was trying to run and the error I got:
import numpy as np
import os
import glob
import cv2
from PIL import Image
import insightface
from insightface.app import FaceAnalysis
from insightface.data import get_image as ins_get_image
app = FaceAnalysis(name="buffalo_l")
app.prepare(ctx_id=0, det_size=(640,640))
img = cv2.imread("friends.png")
rob = cv2.imread("rob.png")
faces = app.get(img)
rob_faces = app.get(rob)
swapper = insightface.model_zoo.get_model('../inswapper_128.onnx',download=False,download_zip=False)
res = img.copy()
for face in faces:
res = swapper.get(res,faces,rob_faces,paste_back=True)
Facing the below issue, while running the above code:
Error:
aimg, M = face_align.norm_crop2(img, target_face.kps, self.input_size[0])
AttributeError: 'list' object has no attribute 'kps'
Any help on this regard would be greatly appreciated. Thanks!
The text was updated successfully, but these errors were encountered:
faces = app.get(img)
returns a list of faces, with each face having its own 'kps'
You need to access individual face's 'kps' via faces[i].kps
Even if there is only one face detected, app.get(img) returns a list of one element.
faces = app.get(img)
If there's only one face detected, then use faces[0] instead of faces
i.e. faces.kps raises error, but not faces[0].kps
In your case, both faces and rob_faces are lists.
You can paste rob_faces[0] (say) onto faces[0] or any other individual faces[i] or all of them (in your case) like:
swapper.get(res, face, rob_faces[0], paste_back = True)
Below is the code I was trying to run and the error I got:
Facing the below issue, while running the above code:
Error:
Any help on this regard would be greatly appreciated. Thanks!
The text was updated successfully, but these errors were encountered: