ltdrdata / ComfyUI-Impact-Pack

Custom nodes pack for ComfyUI This custom node helps to conveniently enhance images through Detector, Detailer, Upscaler, Pipe, and more.
GNU General Public License v3.0
1.89k stars 183 forks source link

Error when running FaceDetailer #210

Closed drago87 closed 1 year ago

drago87 commented 1 year ago

I have a AMD Radeon RX 5700 XT with 8gb vram and are on windows 10 Runnin ComfyUI with the

--directml

command

When i use this workflow facedetailer i get this error

Error occurred when executing FaceRestoreWithModel:

Input type (torch.FloatTensor) and weight type (PrivateUse1FloatType) should be the same or input should be a MKLDNN tensor and weight is a dense tensor

File "D:\AI\ComfyUI_AMD\ComfyUI\execution.py", line 152, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "D:\AI\ComfyUI_AMD\ComfyUI\execution.py", line 82, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
File "D:\AI\ComfyUI_AMD\ComfyUI\execution.py", line 75, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
File "D:\AI\ComfyUI_AMD\ComfyUI\custom_nodes\facerestore\__init__.py", line 145, in restore_face
self.face_helper.get_face_landmarks_5(only_center_face=False, resize=640, eye_dist_threshold=5)
File "D:\AI\ComfyUI_AMD\ComfyUI\custom_nodes\facerestore\facelib\utils\face_restoration_helper.py", line 151, in get_face_landmarks_5
bboxes = self.face_det.detect_faces(input_img)
File "D:\AI\ComfyUI_AMD\ComfyUI\custom_nodes\facerestore\facelib\detection\retinaface\retinaface.py", line 209, in detect_faces
loc, conf, landmarks, priors = self.__detect_faces(image)
File "D:\AI\ComfyUI_AMD\ComfyUI\custom_nodes\facerestore\facelib\detection\retinaface\retinaface.py", line 156, in __detect_faces
loc, conf, landmarks = self(inputs)
File "C:\Users\Drago87\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "D:\AI\ComfyUI_AMD\ComfyUI\custom_nodes\facerestore\facelib\detection\retinaface\retinaface.py", line 121, in forward
out = self.body(inputs)
File "C:\Users\Drago87\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "C:\Users\Drago87\AppData\Local\Programs\Python\Python310\lib\site-packages\torchvision\models\_utils.py", line 69, in forward
x = module(x)
File "C:\Users\Drago87\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "C:\Users\Drago87\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\conv.py", line 463, in forward
return self._conv_forward(input, self.weight, self.bias)
File "C:\Users\Drago87\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\conv.py", line 459, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,

if i connect the hook provider i get this error

Error occurred when executing FaceDetailer:

The size of tensor a (0) must match the size of tensor b (256) at non-singleton dimension 1

File "D:\AI\ComfyUI_AMD\ComfyUI\execution.py", line 152, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "D:\AI\ComfyUI_AMD\ComfyUI\execution.py", line 82, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
File "D:\AI\ComfyUI_AMD\ComfyUI\execution.py", line 75, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
File "D:\AI\ComfyUI_AMD\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\impact_pack.py", line 421, in doit
enhanced_img, cropped_enhanced, cropped_enhanced_alpha, mask, cnet_pil_list = FaceDetailer.enhance_face(
File "D:\AI\ComfyUI_AMD\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\impact_pack.py", line 380, in enhance_face
sam_mask = core.make_sam_mask(sam_model_opt, segs, image, sam_detection_hint, sam_dilation,
File "D:\AI\ComfyUI_AMD\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\core.py", line 401, in make_sam_mask
detected_masks = sam_predict(predictor, points, plabs, dilated_bbox, threshold)
File "D:\AI\ComfyUI_AMD\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\core.py", line 277, in sam_predict
cur_masks, scores, _ = predictor.predict(point_coords=point_coords, point_labels=point_labels, box=box)
File "C:\Users\Drago87\AppData\Local\Programs\Python\Python310\lib\site-packages\segment_anything\predictor.py", line 154, in predict
masks, iou_predictions, low_res_masks = self.predict_torch(
File "C:\Users\Drago87\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "C:\Users\Drago87\AppData\Local\Programs\Python\Python310\lib\site-packages\segment_anything\predictor.py", line 222, in predict_torch
sparse_embeddings, dense_embeddings = self.model.prompt_encoder(
File "C:\Users\Drago87\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "C:\Users\Drago87\AppData\Local\Programs\Python\Python310\lib\site-packages\segment_anything\modeling\prompt_encoder.py", line 155, in forward
point_embeddings = self._embed_points(coords, labels, pad=(boxes is None))
File "C:\Users\Drago87\AppData\Local\Programs\Python\Python310\lib\site-packages\segment_anything\modeling\prompt_encoder.py", line 88, in _embed_points
point_embedding[labels == -1] += self.not_a_point_embed.weight
ltdrdata commented 1 year ago

Try changing the SAM Loader to "Prefer CPU."

drago87 commented 1 year ago

Changing the SAM Loader to CPU works