haofanwang / inswapper Goto Github PK
View Code? Open in Web Editor NEWOne-click Face Swapper and Restoration powered by insightface ๐ฅ
One-click Face Swapper and Restoration powered by insightface ๐ฅ
C:\Users\WOW\AppData\Local\Programs\Python\Python311\Lib\site-packages\insightface\utils\transform.py:68: FutureWarning: rcond
parameter will change to the default of machine precision times max(M, N)
where M and N are the input matrix dimensions.
To use the future default and silence this warning we advise to pass rcond=None
, to keep using the old, explicitly pass rcond=-1
.
P = np.linalg.lstsq(X_homo, Y)[0].T # Affine matrix. 3 x 4
Traceback (most recent call last):
File "C:\Users\WOW\Downloads\Compressed\inswapper-main\main.py", line 7, in
result_image = process(source_img, target_img, -1, -1, model)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\WOW\Downloads\Compressed\inswapper-main\swapper.py", line 184, in process
raise Exception("Unsupported face configuration")
Exception: Unsupported face configuration
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
find model: ./checkpoints/models/buffalo_l/1k3d68.onnx landmark_3d_68 ['None', 3, 192, 192] 0.0 1.0
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
find model: ./checkpoints/models/buffalo_l/2d106det.onnx landmark_2d_106 ['None', 3, 192, 192] 0.0 1.0
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
find model: ./checkpoints/models/buffalo_l/det_10g.onnx detection [1, 3, '?', '?'] 127.5 128.0
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
find model: ./checkpoints/models/buffalo_l/genderage.onnx genderage ['None', 3, 96, 96] 0.0 1.0
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
find model: ./checkpoints/models/buffalo_l/w600k_r50.onnx recognition ['None', 3, 112, 112] 127.5 127.5
set det-size: (320, 320)
Terminated
How to solve the import error of "basicsr. utils. realsrgan_utils"
# import sys
# sys.path.append('./CodeFormer/CodeFormer')
import sys
sys.path.append("/root/autodl-tmp/workspace/inswapper/CodeFormer/CodeFormer")
from basicsr.utils.realesrgan_utils import RealESRGANer
import os
import cv2
import torch
import torch.nn.functional as F
from torchvision.transforms.functional import normalize
from basicsr.utils import imwrite, img2tensor, tensor2img
from basicsr.utils.download_util import load_file_from_url
from facelib.utils.face_restoration_helper import FaceRestoreHelper
from facelib.utils.misc import is_gray
from basicsr.archs.rrdbnet_arch import RRDBNet
# from basicsr.utils.realesrgan_utils import RealESRGANer
from basicsr.utils.registry import ARCH_REGISTRY
be **removed in 0.17**. Please don't rely on it. You probably just need to use APIs in torchvision.transforms.functional or in torchvision.transforms.v2.functional.
warnings.warn(
Traceback (most recent call last):
File "/root/autodl-tmp/workspace/inswapper/swapper.py", line 243, in <module>
from restoration import *
File "/root/autodl-tmp/workspace/inswapper/restoration.py", line 18, in <module>
from basicsr.utils.realesrgan_utils import RealESRGANer
ModuleNotFoundError: No module named 'basicsr.utils.realesrgan_utils'
following the basic example in readme, (swap man1 and man2 into mans1.jpeg) it does not generate the face swap and it throws:
running on a mac, CPU provider
2024-04-10 10:17:33.073537 [E:onnxruntime:, sequential_executor.cc:514 ExecuteKernel] Non-zero status code returned while running CoreML_11777492068329204276_6 node. Name:'CoreMLExecutionProvider_CoreML_11777492068329204276_6_6' Status Message: Exception: /Users/runner/work/1/s/onnxruntime/core/providers/coreml/model/model.mm:71 InlinedVector<int64_t> (anonymous namespace)::GetStaticOutputShape(gsl::span<const int64_t>, gsl::span<const int64_t>, const logging::Logger &) inferred_shape.size() == coreml_static_shape.size() was false. CoreML static output shape ({1,1,1,800,1}) and inferred shape ({3200,1}) have different ranks.
When I run the default test command, it always ends with an error:
Command: python swapper.py --source_img="./data/man1.jpeg;./data/man2.jpeg" --target_img "./data/mans1.jpeg" --source_indexes=0 --target_indexes=0 --face_restore --background_enhance --face_upsample --upscale=2 --codeformer_fidelity=0.5
Error:
Traceback (most recent call last):
File "C:\inswapper\swapper.py", line 239, in
result_image = process(source_img, target_img, args.source_indexes, args.target_indexes, model)
File "C:\inswapper\swapper.py", line 112, in process
temp_frame = swap_face(
File "C:\inswapper\swapper.py", line 67, in swap_face
source_face = source_faces[source_index]
IndexError: list index out of range
But if I run a modified command that only works with the current file, the command passes without any problems
"./data/mans1.jpeg" --source_indexes=0 --target_indexes=0 --background_enhance --face_upsample --upscale=2 --codeformer_fidelity=0.5
restoration.py uses basicsr and facelib libraries and they are not mentioned in the requirements.txt. Current versions of these libraries does not match with the restoration.py. Can you provide pip freeze for the working environment
Command:
python swapper.py --source_img="./inputs/face.png;./inputs/face2.png"
--target_img "./inputs/fb2.png"
--face_restore --background_enhance
--face_upsample --upscale=2 --codeformer_fidelity=0.5
Output:
Source image paths: ['./inputs/face.png', './inputs/face2.png']
Applied providers: ['AzureExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'AzureExecutionProvider': {}}
find model: ./checkpoints/models/buffalo_l/1k3d68.onnx landmark_3d_68 ['None', 3, 192, 192] 0.0 1.0
Applied providers: ['AzureExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'AzureExecutionProvider': {}}
find model: ./checkpoints/models/buffalo_l/2d106det.onnx landmark_2d_106 ['None', 3, 192, 192] 0.0 1.0
Applied providers: ['AzureExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'AzureExecutionProvider': {}}
find model: ./checkpoints/models/buffalo_l/det_10g.onnx detection [1, 3, '?', '?'] 127.5 128.0
Applied providers: ['AzureExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'AzureExecutionProvider': {}}
find model: ./checkpoints/models/buffalo_l/genderage.onnx genderage ['None', 3, 96, 96] 0.0 1.0
Applied providers: ['AzureExecutionProvider', 'CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}, 'AzureExecutionProvider': {}}
find model: ./checkpoints/models/buffalo_l/w600k_r50.onnx recognition ['None', 3, 112, 112] 127.5 127.5
set det-size: (320, 320)
/home//Documents/inswapper/venv/lib64/python3.11/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py:69: UserWarning: Specified provider 'CUDAExecutionProvider' is not in available provider names.Available providers: 'AzureExecutionProvider, CPUExecutionProvider'
warnings.warn(
Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}}
inswapper-shape: [1, 3, 128, 128]
/home//Documents/inswapper/venv/lib64/python3.11/site-packages/insightface/utils/transform.py:68: FutureWarning: rcond
parameter will change to the default of machine precision times max(M, N)
where M and N are the input matrix dimensions.
To use the future default and silence this warning we advise to pass rcond=None
, to keep using the old, explicitly pass rcond=-1
.
P = np.linalg.lstsq(X_homo, Y)[0].T # Affine matrix. 3 x 4
Traceback (most recent call last):
File "/home//Documents/inswapper/swapper.py", line 228, in
result_image = process(source_img, target_img, args.source_indexes, args.target_indexes, model)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home//Documents/inswapper/swapper.py", line 190, in process
raise Exception("Unsupported face configuration")
Exception: Unsupported face configuration
The issue doesn't arise when only using a single source image. I thought it was because i was using 1 png and 1 jpg image, but even using 2 pngs, the issue still arises.
UserWarning: The torchvision.transforms.functional_tensor module is deprecated in 0.15 and will be removed in 0.17. Please don't rely on it. You probably just need to use APIs in torchvision.transforms.functional or in torchvision.transforms.v2.functional.
warnings.warn(
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'facelib.utils.face_restoration_helper'; 'facelib.utils' is not a package
** Update:
I tried to do same as in this post but no success, didn't work the restoration:
#2
I did import the codeformer as well and did everything as require, but still getting this error.
Traceback (most recent call last): File "swapper.py", line 228, in <module> from restoration import * File "/home/ubuntu/inswapper/restoration.py", line 12, in <module> from facelib.utils.face_restoration_helper import FaceRestoreHelper ModuleNotFoundError: No module named 'facelib.utils'
The specified procedure could not be found. Error loading "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\lib\cudnn_adv_infer64_8.dll" or one of its dependencies.
I have cudnn_adv_infer64_8.dll under this folder.
Replacing faces in target image from the left to the right by order
Traceback (most recent call last):
File "C:\Programming\Python\inswapper\swapper.py", line 231, in
from restoration import *
File "C:\Programming\Python\inswapper\restoration.py", line 6, in
import torch
File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\torch_init_.py", line 129, in
raise err
what cause this issue?
Hi,
I really liked your work!!
Could you please give me more information about the model inswapper_128.onnx used, is it a GAN based or diffusion based face swapping model; or any resource that could help me clarify the question ?
Thanks in advance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.