mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-19 11:07:00 +08:00
Attempt to allow for multiple images from the batch
This commit is contained in:
parent
946aa1e4f5
commit
0a11af628b
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,3 +12,4 @@ venv38/
|
|||||||
.idea/
|
.idea/
|
||||||
*.ckpt
|
*.ckpt
|
||||||
*.safetensors
|
*.safetensors
|
||||||
|
models/
|
||||||
|
|||||||
@ -114,19 +114,22 @@ class FaceRestoreWithModel:
|
|||||||
self.face_helper = None
|
self.face_helper = None
|
||||||
|
|
||||||
def restore_face(self, upscale_model, image, facedetection):
|
def restore_face(self, upscale_model, image, facedetection):
|
||||||
|
counter = 0
|
||||||
|
restored_img_list = []
|
||||||
|
for image_itm in image:
|
||||||
device = model_management.get_torch_device()
|
device = model_management.get_torch_device()
|
||||||
upscale_model.to(device)
|
upscale_model.to(device)
|
||||||
if self.face_helper is None:
|
if self.face_helper is None:
|
||||||
self.face_helper = FaceRestoreHelper(1, face_size=512, crop_ratio=(1, 1), det_model=facedetection, save_ext='png', use_parse=True, device=device)
|
self.face_helper = FaceRestoreHelper(1, face_size=512, crop_ratio=(1, 1), det_model=facedetection, save_ext='png', use_parse=True, device=device)
|
||||||
|
|
||||||
image_np = 255. * image.cpu().numpy().squeeze()
|
image_np = 255. * image_itm.cpu().numpy().squeeze()
|
||||||
|
|
||||||
image_np = image_np[:, :, ::-1]
|
image_np = image_np[:, :, ::-1]
|
||||||
|
|
||||||
original_resolution = image_np.shape[0:2]
|
original_resolution = image_np.shape[0:2]
|
||||||
|
|
||||||
if upscale_model is None or self.face_helper is None:
|
if upscale_model is None or self.face_helper is None:
|
||||||
return image
|
return image_itm
|
||||||
|
|
||||||
self.face_helper.clean_all()
|
self.face_helper.clean_all()
|
||||||
self.face_helper.read_image(image_np)
|
self.face_helper.read_image(image_np)
|
||||||
@ -164,11 +167,16 @@ class FaceRestoreWithModel:
|
|||||||
self.face_helper.clean_all()
|
self.face_helper.clean_all()
|
||||||
|
|
||||||
# restored_img = cv2.cvtColor(restored_face, cv2.COLOR_BGR2RGB)
|
# restored_img = cv2.cvtColor(restored_face, cv2.COLOR_BGR2RGB)
|
||||||
|
counter += 1
|
||||||
|
|
||||||
restored_img_np = np.array(restored_img).astype(np.float32) / 255.0
|
restored_img_np = np.array(restored_img).astype(np.float32) / 255.0
|
||||||
restored_img_tensor = torch.from_numpy(restored_img_np).unsqueeze(0)
|
restored_img_tensor = torch.from_numpy(restored_img_np).unsqueeze(0)
|
||||||
|
restored_img_list.append(restored_img_tensor)
|
||||||
|
|
||||||
return (restored_img_tensor,)
|
for i in range(len(image)):
|
||||||
|
image[i] = restored_img_list[i]
|
||||||
|
|
||||||
|
return (image,)
|
||||||
|
|
||||||
NODE_CLASS_MAPPINGS = {
|
NODE_CLASS_MAPPINGS = {
|
||||||
"FaceRestoreWithModel": FaceRestoreWithModel,
|
"FaceRestoreWithModel": FaceRestoreWithModel,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user