Giter VIP home page Giter VIP logo

simswap-colab's Introduction

SimSwap-Colab

The goal of this repository is to provide a Colab notebook to apply SimSwap [1] to images.

Usage

Results

Image source + Image target = Output of SimSwap

Face swapping with a source (left) and a target image (middle). The result is on the right.

Alan Wake feat. Tim SweeneyEGS meme feat. Tim Sweeney

Different results obtained with the face of Tim Sweeney, founder and creator of Epic Games. Left: video game Alan Wake. Right: meme about Epic Games store.

James Franco feat. Tim SweeneyClint Eastwood feat. Tim Sweeney

Different animated results obtained with the face of Tim Sweeney. Left: James Franco in Spider-Man 3 (2007). Right: Clint Eastwood in Gran Torino (2008).

Brent Rambo feat. Tim SweeneyRobert Redford feat. Tim Sweeney

Different animated results obtained with the face of Tim Sweeney. Left: Brent Rambo. Right: Robert Redford in Jeremiah Johnson (1972).

Taylor Armstrong feat. Tim SweeneyJimes Tooper feat. Tim Sweeney

Different results obtained with Tim Sweeney. Left: Taylor Armstrong & Kyle Richards in The Real Housewives of Beverly Hills (2010). Right: Jimes Tooper.

References

[1] Chen, Renwang, et al. SimSwap: An Efficient Framework For High Fidelity Face Swapping. In Proceedings of the 28th ACM International Conference on Multimedia. 2020. (code and paper)

[2] Yang, Tao, et al. GAN Prior Embedded Network for Blind Face Restoration in the Wild. arXiv preprint arXiv:2105.06070. 2021. (code and paper)

simswap-colab's People

Contributors

woctezuma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

simswap-colab's Issues

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

Error with simswap

Sorry to bother you again dude, i get this error on collab:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
torchaudio 2.0.2+cu118 requires torch==2.0.1, but you have torch 1.12.0 which is incompatible.
torchdata 0.6.1 requires torch==2.0.1, but you have torch 1.12.0 which is incompatible.
torchtext 0.15.2 requires torch==2.0.1, but you have torch 1.12.0 which is incompatible.
torchvision 0.15.2+cu118 requires torch==2.0.1, but you have torch 1.12.0 which is incompatible.
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
moviepy 1.0.3 requires imageio<3.0,>=2.5; python_version >= "3.4", but you have imageio 2.4.1 which is incompatible.

AttributeError: module 'numpy' has no attribute 'float'.

!python test_wholeimage_swapsingle.py
/usr/local/lib/python3.10/dist-packages/onnxruntime/capi/onnxruntime_inference_collection.py:69: UserWarning: Specified provider 'CUDAExecutionProvider' is not in available provider names.Available providers: 'AzureExecutionProvider, CPUExecutionProvider'
  warnings.warn(
Downloading: "https://download.pytorch.org/models/resnet18-5c106cde.pth" to /root/.cache/torch/hub/checkpoints/resnet18-5c106cde.pth
100% 44.7M/44.7M [00:00<00:00, 227MB/s]
/usr/local/lib/python3.10/dist-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3526.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
Traceback (most recent call last):
  File "/content/SimSwap/test_wholeimage_swapsingle.py", line 105, in <module>
    reverse2wholeimage(b_align_crop_tenor_list, swap_result_list, b_mat_list, crop_size, img_b_whole, logoclass, \
  File "/content/SimSwap/util/reverse2original.py", line 157, in reverse2wholeimage
    target_image = np.array(target_image, dtype=np.float) * 255
  File "/usr/local/lib/python3.10/dist-packages/numpy/__init__.py", line 319, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'cfloat'?
!python test_wholeimage_swapmulti.py
/usr/local/lib/python3.10/dist-packages/onnxruntime/capi/onnxruntime_inference_collection.py:69: UserWarning: Specified provider 'CUDAExecutionProvider' is not in available provider names.Available providers: 'AzureExecutionProvider, CPUExecutionProvider'
  warnings.warn(
/usr/local/lib/python3.10/dist-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3526.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
Traceback (most recent call last):
  File "/content/SimSwap/test_wholeimage_swapmulti.py", line 106, in <module>
    reverse2wholeimage(b_align_crop_tenor_list,swap_result_list, b_mat_list, crop_size, img_b_whole, logoclass, \
  File "/content/SimSwap/util/reverse2original.py", line 157, in reverse2wholeimage
    target_image = np.array(target_image, dtype=np.float) * 255
  File "/usr/local/lib/python3.10/dist-packages/numpy/__init__.py", line 319, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'cfloat'?

Help

Hi, I would like to hire you for some edits of the code. Please contact me on telegram ($ involved).

@keronikateka

Simswap dont works

Hi dude, i get this error when i try to use simswap
AttributeError: 'dict' object has no attribute 'to'

thanks for all your work!

Unpickling error

Not a coder by trade, I had it working for a while with great results but now it won't run.
Getting this error every time I run Official Code:

UnpicklingError Traceback (most recent call last)
in ()
13
14 torch.nn.Module.dump_patches = True
---> 15 model = create_model(opt)
16 model.eval()
17

3 frames
/content/SimSwap/models/models.py in create_model(opt)
16 model = UIModel()
17
---> 18 model.initialize(opt)
19 if opt.verbose:
20 print("model [%s] was created" % (model.name()))

/content/SimSwap/models/fs_model.py in initialize(self, opt)
62 # Id network
63 netArc_checkpoint = opt.Arc_path
---> 64 netArc_checkpoint = torch.load(netArc_checkpoint)
65 self.netArc = netArc_checkpoint['model'].module
66 self.netArc = self.netArc.to(device)

/usr/local/lib/python3.7/dist-packages/torch/serialization.py in load(f, map_location, pickle_module, **pickle_load_args)
606 return torch.jit.load(opened_file)
607 return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
--> 608 return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
609
610

/usr/local/lib/python3.7/dist-packages/torch/serialization.py in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
775 "functionality.")
776
--> 777 magic_number = pickle_module.load(f, **pickle_load_args)
778 if magic_number != MAGIC_NUMBER:
779 raise RuntimeError("Invalid magic number; corrupt file?")

UnpicklingError: invalid load key, '<'.

Can swap specific attribute

Hey, I was wondering if instead of the whole face only a specific attribute can be swapped? For eg, eyeglasses or a cap or something like that.

I really appreciate any help you can provide.

.......

Why did you delete my issue? im offering you money for an edit.. do you have skype or whats the best way to contact you?

simswap dont works

hi pal, first of all thankyou for all your job, its awesome, last days ive getting this trouble:

/content/SimSwap
/usr/local/lib/python3.8/dist-packages/torch/serialization.py:868: SourceChangeWarning: source code of class 'torch.nn.parallel.data_parallel.DataParallel' has changed. Saved a reverse patch to DataParallel.patch. Run patch -p0 < DataParallel.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
/usr/local/lib/python3.8/dist-packages/torch/serialization.py:868: SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv2d' has changed. Tried to save a patch, but couldn't create a writable file Conv2d.patch. Make sure it doesn't exist and your working directory is writable.
warnings.warn(msg, SourceChangeWarning)
/usr/local/lib/python3.8/dist-packages/torch/serialization.py:868: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.BatchNorm2d' has changed. Saved a reverse patch to BatchNorm2d.patch. Run patch -p0 < BatchNorm2d.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
/usr/local/lib/python3.8/dist-packages/torch/serialization.py:868: SourceChangeWarning: source code of class 'torch.nn.modules.activation.PReLU' has changed. Saved a reverse patch to PReLU.patch. Run patch -p0 < PReLU.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
/usr/local/lib/python3.8/dist-packages/torch/serialization.py:868: SourceChangeWarning: source code of class 'torch.nn.modules.pooling.MaxPool2d' has changed. Saved a reverse patch to MaxPool2d.patch. Run patch -p0 < MaxPool2d.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
/usr/local/lib/python3.8/dist-packages/torch/serialization.py:868: SourceChangeWarning: source code of class 'torch.nn.modules.container.Sequential' has changed. Saved a reverse patch to Sequential.patch. Run patch -p0 < Sequential.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
/usr/local/lib/python3.8/dist-packages/torch/serialization.py:868: SourceChangeWarning: source code of class 'torch.nn.modules.pooling.AdaptiveAvgPool2d' has changed. Saved a reverse patch to AdaptiveAvgPool2d.patch. Run patch -p0 < AdaptiveAvgPool2d.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
/usr/local/lib/python3.8/dist-packages/torch/serialization.py:868: SourceChangeWarning: source code of class 'torch.nn.modules.linear.Linear' has changed. Saved a reverse patch to Linear.patch. Run patch -p0 < Linear.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
/usr/local/lib/python3.8/dist-packages/torch/serialization.py:868: SourceChangeWarning: source code of class 'torch.nn.modules.activation.Sigmoid' has changed. Saved a reverse patch to Sigmoid.patch. Run patch -p0 < Sigmoid.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
/usr/local/lib/python3.8/dist-packages/torch/serialization.py:868: SourceChangeWarning: source code of class 'torch.nn.modules.dropout.Dropout' has changed. Saved a reverse patch to Dropout.patch. Run patch -p0 < Dropout.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
/usr/local/lib/python3.8/dist-packages/torch/serialization.py:868: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.BatchNorm1d' has changed. Saved a reverse patch to BatchNorm1d.patch. Run patch -p0 < BatchNorm1d.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
Traceback (most recent call last):
File "test_wholeimage_swapsingle.py", line 51, in
model = create_model(opt)
File "/content/SimSwap/models/models.py", line 18, in create_model
model.initialize(opt)
File "/content/SimSwap/models/fs_model.py", line 67, in initialize
netArc_checkpoint = torch.load(netArc_checkpoint)
File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 795, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 1012, in _legacy_load
result = unpickler.load()
File "/usr/local/lib/python3.8/dist-packages/torch/optim/sgd.py", line 112, in setstate
super().setstate(state)
File "/usr/local/lib/python3.8/dist-packages/torch/optim/optimizer.py", line 84, in setstate
self.defaults.setdefault('differentiable', False)
AttributeError: 'SGD' object has no attribute 'defaults'

thanks!!

Issue with Simswap

Hi ! get this error when i run it
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
moviepy 1.0.3 requires imageio<3.0,>=2.5; python_version >= "3.4", but you have imageio 2.4.1 which is incompatible.

...

You referred me to the official version but the offical version does not ofer gpen post processing so im not sure why you did that, so im asking you since you did this notebook, do you wanna edit some files for me and get paid?

Problem with providers

-------------- End ----------------

ValueError Traceback (most recent call last)
in <cell line: 29>()
27
28
---> 29 app = Face_detect_crop(name='antelope', root='./insightface_func/models')
30 app.prepare(ctx_id= 0, det_thresh=det_thresh, det_size=det_size, mode=mode)
31

5 frames
/usr/local/lib/python3.10/dist-packages/onnxruntime/capi/onnxruntime_inference_collection.py in _create_inference_session(self, providers, provider_options, disabled_optimizers)
449 if not providers and len(available_providers) > 1:
450 self.disable_fallback()
--> 451 raise ValueError(
452 f"This ORT build has {available_providers} enabled. "
453 "Since ORT 1.9, you are required to explicitly set "

ValueError: This ORT build has ['AzureExecutionProvider', 'CPUExecutionProvider'] enabled. Since ORT 1.9, you are required to explicitly set the providers parameter when instantiating InferenceSession. For example, onnxruntime.InferenceSession(..., providers=['AzureExecutionProvider', 'CPUExecutionProvider'], ...)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.