Skip to content

fix bug of first order multi person #329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ppgan/apps/first_order_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

from .base_predictor import BasePredictor

IMAGE_SIZE = 256

class FirstOrderPredictor(BasePredictor):
def __init__(self,
Expand Down Expand Up @@ -105,7 +106,6 @@ def __init__(self,

def read_img(self, path):
img = imageio.imread(path)
img = img.astype(np.float32)
if img.ndim == 2:
img = np.expand_dims(img, axis=2)
# som images have 4 channels
Expand Down Expand Up @@ -161,14 +161,14 @@ def get_prediction(face_image):
reader.close()

driving_video = [
cv2.resize(frame, (256, 256)) / 255.0 for frame in driving_video
cv2.resize(frame, (IMAGE_SIZE, IMAGE_SIZE)) / 255.0 for frame in driving_video
]
results = []

# for single person
if not self.multi_person:
h, w, _ = source_image.shape
source_image = cv2.resize(source_image, (256, 256)) / 255.0
source_image = cv2.resize(source_image, (IMAGE_SIZE, IMAGE_SIZE)) / 255.0
predictions = get_prediction(source_image)
imageio.mimsave(os.path.join(self.output, self.filename), [
cv2.resize((frame * 255.0).astype('uint8'), (h, w))
Expand All @@ -181,7 +181,7 @@ def get_prediction(face_image):
print(str(len(bboxes)) + " persons have been detected")
if len(bboxes) <= 1:
h, w, _ = source_image.shape
source_image = cv2.resize(source_image, (256, 256)) / 255.0
source_image = cv2.resize(source_image, (IMAGE_SIZE, IMAGE_SIZE)) / 255.0
predictions = get_prediction(source_image)
imageio.mimsave(os.path.join(self.output, self.filename), [
cv2.resize((frame * 255.0).astype('uint8'), (h, w))
Expand All @@ -193,7 +193,7 @@ def get_prediction(face_image):
# for multi person
for rec in bboxes:
face_image = source_image.copy()[rec[1]:rec[3], rec[0]:rec[2]]
face_image = cv2.resize(face_image, (256, 256)) / 255.0
face_image = cv2.resize(face_image, (IMAGE_SIZE, IMAGE_SIZE)) / 255.0
predictions = get_prediction(face_image)
results.append({'rec': rec, 'predict': predictions})

Expand Down