AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
142.17k stars 26.84k forks source link

RuntimeError when using Restore faces option (possible incompatible PyTorch - torchvision) #984

Closed timograw closed 1 year ago

timograw commented 2 years ago

Describe the bug RuntimeError when using Restore faces option (possible incompatible PyTorch - torchvision)

To Reproduce Steps to reproduce the behavior: Use txt2img or img2img with the Restore faces option activated

img2img Console output (after successful latent-diffusion)

/home/timo/stable-diffusion-webui/venv/lib/python3.8/site-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and will be removed in 0.15, please use 'weights' instead.
  warnings.warn(
/home/timo/stable-diffusion-webui/venv/lib/python3.8/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and will be removed in 0.15. The current behavior is equivalent to passing `weights=None`.
  warnings.warn(msg)
Error completing request
Arguments: (0, '', '', 'None', 'None', <PIL.Image.Image image mode=RGB size=512x512 at 0x7F6E4EC7E220>, None, None, None, 0, 20, 0, 4, 0, True, False, 1, 1, 7, 0.75, -1.0, -1.0, 0, 0, 0, False, 512, 512, 0, False, 32, 0, '', '', 0, 4, 1, 1, '', 4, '', True, False, '<p style="margin-bottom:0.75em">Will upscale the image to twice the dimensions; use width and height sliders to set tile size</p>', 64, 0, 128, 4, 0, ['left', 'right', 'up', 'down'], False, None, '', False, '', '', 1, 50, 0, '<p style="margin-bottom:0.75em">Recommended settings: Sampling Steps: 80-100, Sampler: Euler a, Denoising strength: 0.8</p>', 128, 4, ['left', 'right', 'up', 'down'], 1, 0.05) {}
Traceback (most recent call last):
  File "/home/timo/stable-diffusion-webui/modules/ui.py", line 136, in f
    res = list(func(*args, **kwargs))
  File "/home/timo/stable-diffusion-webui/webui.py", line 59, in f
    res = func(*args, **kwargs)
  File "/home/timo/stable-diffusion-webui/modules/img2img.py", line 117, in img2img
    processed = process_images(p)
  File "/home/timo/stable-diffusion-webui/modules/processing.py", line 367, in process_images
    x_sample = modules.face_restoration.restore_faces(x_sample)
  File "/home/timo/stable-diffusion-webui/modules/face_restoration.py", line 19, in restore_faces
    return face_restorer.restore(np_image)
  File "/home/timo/stable-diffusion-webui/modules/codeformer_model.py", line 79, in restore
    self.face_helper.get_face_landmarks_5(only_center_face=False, resize=640, eye_dist_threshold=5)
  File "/home/timo/stable-diffusion-webui/repositories/CodeFormer/facelib/utils/face_restoration_helper.py", line 151, in get_face_landmarks_5
    bboxes = self.face_det.detect_faces(input_img)
  File "/home/timo/stable-diffusion-webui/repositories/CodeFormer/facelib/detection/retinaface/retinaface.py", line 231, in detect_faces
    keep = py_cpu_nms(bounding_boxes, nms_threshold)
  File "/home/timo/stable-diffusion-webui/repositories/CodeFormer/facelib/detection/retinaface/retinaface_utils.py", line 41, in py_cpu_nms
    keep = torchvision.ops.nms(
  File "/home/timo/stable-diffusion-webui/venv/lib/python3.8/site-packages/torchvision/ops/boxes.py", line 40, in nms
    _assert_has_ops()
  File "/home/timo/stable-diffusion-webui/venv/lib/python3.8/site-packages/torchvision/extension.py", line 33, in _assert_has_ops
    raise RuntimeError(
RuntimeError: Couldn't load custom C++ ops. This can happen if your PyTorch and torchvision versions are incompatible, or if you had errors while compiling torchvision from source. For further information on the compatible versions, check https://github.com/pytorch/vision#installation for the compatibility matrix. Please check your PyTorch version with torch.__version__ and your torchvision version with torchvision.__version__ and verify if they are compatible, and if not please reinstall torchvision so that it matches your PyTorch install.

Desktop (please complete the following information):

Additional context I'm a developer but also completely new to python. If you have any hints on what to test or do, please go ahead.

EndlessReform commented 2 years ago

I also had this error, but @leszekhanusz's solution from #564 solved it for me (on Linux) as a workaround. Would still be good to do something about this officially though

ShadowFireSage commented 2 years ago

is there a solution for windows?

ClashSAN commented 1 year ago

this is an old issue which is fixed and no longer seems relevant, if this issue is related to future issues, please refer to this previous one.