Git Product home page Git Product logo

faceswap-ios's Introduction

Contributor Covenant

FaceSwap iOS

Face swap for iOS.

Background

In 2018 I decided to publish code for face swapping in Android here. I also made a face swap app for iOS.

Previous implementation depended on dlib, but it was a bit tricky to compile dlib for iOS. When Apple announced that they will support facial landmarks detection in iOS dlib was ditched. Facial landmarks are coordinates detected in a face observation. See image below for example of landmarks used. Note that all facial landmarks have not been used. Facial landmarks for eyes, mouth and nose were discarded since these will not be used by the swap algorithm. Furthermore, the landmarks coordinates for the eyebrows were adjusted slightly to include a bit of the forehead. Without adjusting those coordinates, the face swap might result in two kinds of eyebrows overlapping each other.

Dependencies

The app depends on OpenCV. It should be straightforward to add the OpenCV library to Xcode. The code that depend on OpenCV is Objective-C++ (.mm). There is a bridging-header provided not to expose C++ code to Swift.

Due to OpenCV's size, the framework was not pushed to this repository. Download it from here, in this project OpenCV-3.4.9 is used. Unzip opencv2.framework.zip, drag it to Xcode and select "Copy items if needed". The app should work with previous releases, which may reduce the app size.

To make Xcode understand that the framework exists, see the images below:

App interface

Really simple. A segment button to switch between the input photos. Tap on the screen to select photo from the camera roll. Then press the arrow to swap faces. When face swap is finished, tap the action button to share the result.

Interface

Input example

Thank you Leonardo and Brad for lending your faces.

Result

Share result

Donate

Paypal

Paypal

paypal

faceswap-ios's People

Contributors

kant 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

Watchers

 avatar

faceswap-ios's Issues

Does not run on Apple arm M1 processors (iOS emulator)

I was going to update the UI to SwiftUI and noticed that the app couldn't run on the new Apple arm M1 processors.
There's also a problem with OpenCV, I hardly think it will compile. But even before a single OpenCV function is called, Apple is signaling about some error. Could it be that the Vision-framework is not flying on M1 as well?

2020-12-22 09:47:01.233413+0100 FaceSwap[61513:4671609] [AXRuntimeCommon] Unknown client: FaceSwap
Primary action
Fatal error: unexpected result type!: file FaceSwap/FaceSwapLogic.swift, line 111
2020-12-22 09:47:10.012046+0100 FaceSwap[61513:4671414] Fatal error: unexpected result type!: file FaceSwap/FaceSwapLogic.swift, line 111
(lldb) 

If anyone knows how to fix it, please share.

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.