未验证 提交 bab376f4 编写于 作者: F FNRE 提交者: GitHub

fix fom deform (#333)

上级 60c41c2f
...@@ -165,30 +165,8 @@ class FirstOrderPredictor(BasePredictor): ...@@ -165,30 +165,8 @@ class FirstOrderPredictor(BasePredictor):
] ]
results = [] results = []
# for single person
if not self.multi_person:
h, w, _ = source_image.shape
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))
for frame in predictions
],
fps=fps)
return
bboxes = self.extract_bbox(source_image.copy()) bboxes = self.extract_bbox(source_image.copy())
print(str(len(bboxes)) + " persons have been detected") print(str(len(bboxes)) + " persons have been detected")
if len(bboxes) <= 1:
h, w, _ = source_image.shape
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))
for frame in predictions
],
fps=fps)
return
# for multi person # for multi person
for rec in bboxes: for rec in bboxes:
...@@ -196,7 +174,8 @@ class FirstOrderPredictor(BasePredictor): ...@@ -196,7 +174,8 @@ class FirstOrderPredictor(BasePredictor):
face_image = cv2.resize(face_image, (IMAGE_SIZE, IMAGE_SIZE)) / 255.0 face_image = cv2.resize(face_image, (IMAGE_SIZE, IMAGE_SIZE)) / 255.0
predictions = get_prediction(face_image) predictions = get_prediction(face_image)
results.append({'rec': rec, 'predict': predictions}) results.append({'rec': rec, 'predict': predictions})
if len(bboxes) == 1 or not self.multi_person:
break
out_frame = [] out_frame = []
for i in range(len(driving_video)): for i in range(len(driving_video)):
...@@ -209,6 +188,7 @@ class FirstOrderPredictor(BasePredictor): ...@@ -209,6 +188,7 @@ class FirstOrderPredictor(BasePredictor):
out = cv2.resize(out.astype(np.uint8), (x2 - x1, y2 - y1)) out = cv2.resize(out.astype(np.uint8), (x2 - x1, y2 - y1))
if len(results) == 1: if len(results) == 1:
frame[y1:y2, x1:x2] = out frame[y1:y2, x1:x2] = out
break
else: else:
patch = np.zeros(frame.shape).astype('uint8') patch = np.zeros(frame.shape).astype('uint8')
patch[y1:y2, x1:x2] = out patch[y1:y2, x1:x2] = out
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册