Gourieff / sd-webui-reactor

Fast and Simple Face Swap Extension for StableDiffusion WebUI (A1111 SD WebUI, SD WebUI Forge, SD.Next, Cagliostro)
GNU Affero General Public License v3.0
2.56k stars 281 forks source link

[SOLVED] Codeformer Issue #365

Closed Redzahh71 closed 9 months ago

Redzahh71 commented 9 months ago

First, confirm

What happened?

I use the ReActor Ext on Auto1111. Online on vast.ai Never an issue. Brilliant. Tonight it's not working when codeformer is selected(default). On Auto1111 codeformer is separately installed as a face restoration option in settings. This also not working. Apologies if this isn't a ReActor issue but I thought I'd let you know. I've tried updating the ext to get latest version. I've tried with many different checkpoints to rule that out.

Steps to reproduce the problem

  1. Go to ....
  2. Press ....
  3. ...

Sysinfo

Auto 1111 from vast.ai Never a problem.

Relevant console log

1

Additional information

No response

Gourieff commented 9 months ago

Maybe there's smth wrong with the codeformer model file Try to download it again from this dataset: https://huggingface.co/datasets/Gourieff/ReActor/tree/main/models/facerestore_models and put it to the models\Codeformer folder

Redzahh71 commented 9 months ago

Yes. That worked. I had to download 3 files in total. Thanks Ciaran.

Sent from Outlook for Androidhttps://aka.ms/AAb9ysg


From: Eugene Gourieff @.> Sent: Tuesday, February 20, 2024 11:10:40 AM To: Gourieff/sd-webui-reactor @.> Cc: Redzahh71 @.>; Author @.> Subject: Re: [Gourieff/sd-webui-reactor] Codeformer Issue (Issue #365)

Maybe there's smth wrong with the codeformer model file Try to download it again from this dataset: https://huggingface.co/datasets/Gourieff/ReActor/tree/main/models/facerestore_models and put it to the models\Codeformer folder

— Reply to this email directly, view it on GitHubhttps://github.com/Gourieff/sd-webui-reactor/issues/365#issuecomment-1953983150, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BGI4IFPE236RPOB4OL4F2W3YUSADBAVCNFSM6AAAAABDQEHEHGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJTHE4DGMJVGA. You are receiving this because you authored the thread.Message ID: @.***>

AdamTHH commented 9 months ago

Similar problem, though I have the model files, I seem to get a PermissionError when downloading the weights This also started happening about 5 days ago

13:56:50 - ReActor - STATUS - Restoring the face with CodeFormer
Downloading: "https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth" to /opt/stable-diffusion-webui/repositories/CodeFormer/weights/facelib/detection_Resnet50_Final.pth

*** Error running postprocess_image: /opt/stable-diffusion-webui/extensions/sd-webui-reactor/scripts/reactor_faceswap.py
    Traceback (most recent call last):
      File "/opt/stable-diffusion-webui/modules/scripts.py", line 774, in postprocess_image
        script.postprocess_image(p, pp, *script_args)
      File "/opt/stable-diffusion-webui/extensions/sd-webui-reactor/scripts/reactor_faceswap.py", line 443, in postprocess_image
        result, output, swapped = swap_face(
      File "/opt/stable-diffusion-webui/extensions/sd-webui-reactor/scripts/reactor_swapper.py", line 615, in swap_face
        result_image, output, swapped = operate(source_img,target_img,target_img_orig,model,source_faces_index,faces_index,source_faces,target_faces,gender_source,gender_target,source_face,wrong_gender,source_age,source_gender,output,swapped,mask_face,entire_mask_image,enhancement_options,detection_options)
      File "/opt/stable-diffusion-webui/extensions/sd-webui-reactor/scripts/reactor_swapper.py", line 811, in operate
        result_image = enhance_image(result_image, enhancement_options)
      File "/opt/stable-diffusion-webui/extensions/sd-webui-reactor/scripts/reactor_swapper.py", line 216, in enhance_image
        result_image = restore_face(result_image, enhancement_options)
      File "/opt/stable-diffusion-webui/extensions/sd-webui-reactor/scripts/reactor_swapper.py", line 172, in restore_face
        numpy_image = codeformer_model.codeformer.restore(
      File "/opt/stable-diffusion-webui/modules/codeformer_model.py", line 81, in restore
        self.create_models()
      File "/opt/stable-diffusion-webui/modules/codeformer_model.py", line 64, in create_models
        face_helper = FaceRestoreHelper(1, face_size=512, crop_ratio=(1, 1), det_model='retinaface_resnet50', save_ext='png', use_parse=True, device=devices.device_codeformer)
      File "/opt/stable-diffusion-webui/repositories/CodeFormer/facelib/utils/face_restoration_helper.py", line 105, in __init__
        self.face_det = init_detection_model(det_model, half=False, device=self.device)
      File "/opt/stable-diffusion-webui/repositories/CodeFormer/facelib/detection/__init__.py", line 16, in init_detection_model
        model = init_retinaface_model(model_name, half, device)
      File "/opt/stable-diffusion-webui/repositories/CodeFormer/facelib/detection/__init__.py", line 35, in init_retinaface_model
        model_path = load_file_from_url(url=model_url, model_dir='weights/facelib', progress=True, file_name=None)
      File "/opt/stable-diffusion-webui/repositories/CodeFormer/facelib/utils/misc.py", line 100, in load_file_from_url
        download_url_to_file(url, cached_file, hash_prefix=None, progress=progress)
      File "/opt/micromamba/envs/webui/lib/python3.10/site-packages/torch/hub.py", line 638, in download_url_to_file
        f = open(tmp_dst, 'w+b')
    PermissionError: [Errno 13] Permission denied: '/opt/stable-diffusion-webui/repositories/CodeFormer/weights/facelib/detection_Resnet50_Final.pth.7533f9348d8f4440b2da0deeafcaf4f1.partial'
Redzahh71 commented 9 months ago

Adam. The version of Automatic 1111 that I access in the cloud through vast.ai, is firing up "without" 2 of the 3 files required for codeformer to work properly. So I'm having to manually upload them to their respective folder each time. Is this an Auto 1111 issue?