neuralchen / SimSwap

An arbitrary face-swapping framework on images and videos with one single trained model!
Other
4.41k stars 872 forks source link

Instructions for Ubuntu 22.04 #419

Open gteachey opened 1 year ago

gteachey commented 1 year ago

I have no idea whether I'm running something unique, but these instructions do not work for me. At all.

After a treacherous day of hunting, here's the commands that worked to get this running for me in case it helps someone else:

Thank you https://github.com/gillesvandevoorde and https://github.com/mike9251 for the assists. conda create -n simswap python=3.8 conda activate simswap export CMAKE_ARGS="-DONNX_USE_PROTOBUF_SHARED_LIBS=ON" conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia conda install cudatoolkit -c pytorch pip install --ignore-installed imageio pip install insightface==0.2.1 onnxruntime moviepy pip install onnxruntime-gpu

EDIT: Of course I miss a command! pip install "numpy<1.24"

find your installation of 'model_zoo.py'. I was running miniconda so it was under my ~/miniconda directory. vim ~/miniconda3/envs/simswap2/lib/python3.8/site-packages/insightface/model_zoo/model_zoo.py

Update the line def get_model(self): session = onnxruntime.InferenceSession(self.onnx_file, None) to def get_model(self): session = onnxruntime.InferenceSession(self.onnx_file, providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])

And I'm off to the races and doing swaps :).

Links referenced: https://github.com/neuralchen/SimSwap/issues/395#issuecomment-1509889573 https://github.com/mike9251/simswap-inference-pytorch

geekbleek commented 1 year ago

This worked for me - thank you!

GoodFanxinran commented 1 year ago

Hi, I follow your steps and install the environments successfully, Thank you so much!! But I have another question when I do the 'python test_one_image.py --name people --Arc_path arcface_model/arcface_checkpoint.tar --pic_a_path crop_224/6.jpg --pic_b_path crop_224/ds.jpg --output_path output/ ', I got the error: 'Pretrained network G has fewer layers; The following are not initialized: ['down0', 'first_layer', 'last_layer', 'up0']'. Have you ever met this? I will be very appreciated if you can give me some advice!!

sr1dh4r commented 7 months ago

This resolved the issues for me but I seem to be getting sub-optimal results. The demo video from test_video_swapsingle.py is very jittery and the output image is not properly swapped. Are you getting good results ? Could this be because we are not using the py 3.6 environment originally mentioned ?