jhj0517
commited on
Commit
•
f3bd536
1
Parent(s):
2ce5fe4
Fix output img type
Browse files
modules/live_portrait/live_portrait_inferencer.py
CHANGED
@@ -138,7 +138,7 @@ class LivePortraitInferencer:
|
|
138 |
rotate_yaw = -rotate_yaw
|
139 |
|
140 |
new_editor_link = None
|
141 |
-
if motion_link
|
142 |
self.psi = motion_link[0]
|
143 |
new_editor_link = motion_link.copy()
|
144 |
elif src_image is not None:
|
@@ -160,7 +160,7 @@ class LivePortraitInferencer:
|
|
160 |
|
161 |
es = ExpressionSet()
|
162 |
|
163 |
-
if sample_image
|
164 |
if id(self.sample_image) != id(sample_image):
|
165 |
self.sample_image = sample_image
|
166 |
d_image_np = (sample_image * 255).byte().numpy()
|
@@ -200,14 +200,13 @@ class LivePortraitInferencer:
|
|
200 |
crop_with_fullsize = cv2.warpAffine(crop_out, psi.crop_trans_m, get_rgb_size(psi.src_rgb), cv2.INTER_LINEAR)
|
201 |
out = np.clip(psi.mask_ori * crop_with_fullsize + (1 - psi.mask_ori) * psi.src_rgb, 0, 255).astype(np.uint8)
|
202 |
|
203 |
-
out_img = pil2tensor(out)
|
204 |
out_img_path = get_auto_incremental_file_path(TEMP_DIR, "png")
|
205 |
|
206 |
img = Image.fromarray(crop_out)
|
207 |
-
img.save(out_img_path, compress_level=1)
|
208 |
new_editor_link.append(es)
|
209 |
|
210 |
-
return
|
211 |
except Exception as e:
|
212 |
raise
|
213 |
|
|
|
138 |
rotate_yaw = -rotate_yaw
|
139 |
|
140 |
new_editor_link = None
|
141 |
+
if isinstance(motion_link, np.ndarray) and motion_link:
|
142 |
self.psi = motion_link[0]
|
143 |
new_editor_link = motion_link.copy()
|
144 |
elif src_image is not None:
|
|
|
160 |
|
161 |
es = ExpressionSet()
|
162 |
|
163 |
+
if isinstance(sample_image, np.ndarray) and sample_image:
|
164 |
if id(self.sample_image) != id(sample_image):
|
165 |
self.sample_image = sample_image
|
166 |
d_image_np = (sample_image * 255).byte().numpy()
|
|
|
200 |
crop_with_fullsize = cv2.warpAffine(crop_out, psi.crop_trans_m, get_rgb_size(psi.src_rgb), cv2.INTER_LINEAR)
|
201 |
out = np.clip(psi.mask_ori * crop_with_fullsize + (1 - psi.mask_ori) * psi.src_rgb, 0, 255).astype(np.uint8)
|
202 |
|
|
|
203 |
out_img_path = get_auto_incremental_file_path(TEMP_DIR, "png")
|
204 |
|
205 |
img = Image.fromarray(crop_out)
|
206 |
+
img.save(out_img_path, compress_level=1, format="png")
|
207 |
new_editor_link.append(es)
|
208 |
|
209 |
+
return out # {"ui": {"images": results}, "result": (out_img, new_editor_link, es)}
|
210 |
except Exception as e:
|
211 |
raise
|
212 |
|