Skip to content

Error when trying to use "Restore faces" #43

@miguelmarco

Description

@miguelmarco

Describe the bug
I get the following error on the command line if I try to use the "restore faces" option.

/home/mmarco/stable-diffusion-krita-plugin/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/mmarco/stable-diffusion-krita-plugin/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:    Exception in ASGI application
Traceback (most recent call last):
  File "/home/mmarco/stable-diffusion-krita-plugin/venv/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 404, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/home/mmarco/stable-diffusion-krita-plugin/venv/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/home/mmarco/stable-diffusion-krita-plugin/venv/lib/python3.8/site-packages/fastapi/applications.py", line 269, in __call__
    await super().__call__(scope, receive, send)
  File "/home/mmarco/stable-diffusion-krita-plugin/venv/lib/python3.8/site-packages/starlette/applications.py", line 124, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/mmarco/stable-diffusion-krita-plugin/venv/lib/python3.8/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/home/mmarco/stable-diffusion-krita-plugin/venv/lib/python3.8/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/home/mmarco/stable-diffusion-krita-plugin/venv/lib/python3.8/site-packages/starlette/exceptions.py", line 93, in __call__
    raise exc
  File "/home/mmarco/stable-diffusion-krita-plugin/venv/lib/python3.8/site-packages/starlette/exceptions.py", line 82, in __call__
    await self.app(scope, receive, sender)
  File "/home/mmarco/stable-diffusion-krita-plugin/venv/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/home/mmarco/stable-diffusion-krita-plugin/venv/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/home/mmarco/stable-diffusion-krita-plugin/venv/lib/python3.8/site-packages/starlette/routing.py", line 670, in __call__
    await route.handle(scope, receive, send)
  File "/home/mmarco/stable-diffusion-krita-plugin/venv/lib/python3.8/site-packages/starlette/routing.py", line 266, in handle
    await self.app(scope, receive, send)
  File "/home/mmarco/stable-diffusion-krita-plugin/venv/lib/python3.8/site-packages/starlette/routing.py", line 65, in app
    response = await func(request)
  File "/home/mmarco/stable-diffusion-krita-plugin/venv/lib/python3.8/site-packages/fastapi/routing.py", line 231, in app
    raw_response = await run_endpoint_function(
  File "/home/mmarco/stable-diffusion-krita-plugin/venv/lib/python3.8/site-packages/fastapi/routing.py", line 160, in run_endpoint_function
    return await dependant.call(**values)
  File "/home/mmarco/stable-diffusion-krita-plugin/krita_server.py", line 185, in f_txt2img
    output_images, info, html = modules.txt2img.txt2img(
  File "/home/mmarco/stable-diffusion-krita-plugin/modules/txt2img.py", line 42, in txt2img
    processed = process_images(p)
  File "/home/mmarco/stable-diffusion-krita-plugin/modules/processing.py", line 359, in process_images
    x_sample = modules.face_restoration.restore_faces(x_sample)
  File "/home/mmarco/stable-diffusion-krita-plugin/modules/face_restoration.py", line 19, in restore_faces
    return face_restorer.restore(np_image)
  File "/home/mmarco/stable-diffusion-krita-plugin/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/mmarco/stable-diffusion-krita-plugin/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/mmarco/stable-diffusion-krita-plugin/repositories/CodeFormer/facelib/detection/retinaface/retinaface.py", line 231, in detect_faces
    keep = py_cpu_nms(bounding_boxes, nms_threshold)
  File "/home/mmarco/stable-diffusion-krita-plugin/repositories/CodeFormer/facelib/detection/retinaface/retinaface_utils.py", line 41, in py_cpu_nms
    keep = torchvision.ops.nms(
  File "/home/mmarco/stable-diffusion-krita-plugin/venv/lib/python3.8/site-packages/torchvision/ops/boxes.py", line 40, in nms
    _assert_has_ops()
  File "/home/mmarco/stable-diffusion-krita-plugin/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.

Total progress: 20it [00:16, 13.72it/s]

To Reproduce
Steps to reproduce the behavior:

  1. Select the "Restore faces" checkbox
  2. Click on 'Apply txt2img'
  3. See error

Expected behavior
An image would be created

Desktop (please complete the following information):

  • OS: Linux

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions