How to Replace a Face in a Photograph using Neural Networks (2024)

Updated: June 6, 2024 Author: Vitaly

Replacing a face in a photo is a fun and creative process that will bring a lot of joy. From creating funny memes to restoring damaged photos, the possibilities are endless. In this article, we'll look at how you can easily replace a face on a photo using the tools available and programs.

Table of Contents

How to Replace a Face in a Photograph using Neural Networks (1)

Deepfake is a technology that, using neural networks, makes it possible to easily replace a person’s face in a photo, and the resulting new image will have such a natural appearance that it is difficult to distinguish it from a real photograph. Just a few years ago, this technical solution was mainly used by attackers to compromise a person, but now this opportunity is available to everyone.

There are a number of completely appropriate situations for replacing your face or the face of another person in a photograph. With simple manipulations you can create fun, surreal images for fun or use them to create better photographs of yourself. For example, you want to create a business profile on social networks, but you don’t have time to take a high-quality photo in a suit. With face replacement, you can take a suitable photo from the Internet and insert your face into it.

Replacing a face in a photo is a powerful tool that can be used for both creative and practical purposes. However, to obtain a high-quality result, you need the appropriate tools and the ability to work with them.

With the development of neural network technologies, high-quality replacement of a face in a photograph is no longer an incredibly difficult task. Today, graphic editors and neural networks are available to users.

Until recently, programs such as Photoshop or GIMP were the only way to replace a person's face in a photo. Often, by the term “Photoshop” people don’t even understand the program, but a photograph artificially modified in the editor. You've probably often heard the phrase “it's Photoshop!” However, for a person who is not involved in design, these tools are too complex, and the process of replacing a face in Photoshop, and especially in GIMP, is very labor-intensive. Therefore, they are worth mentioning as an option, but in most cases, image editors are not suitable for the general public. Of course, the introduction of neural network technologies by Adobe in Photoshop and OpenVino from Intel in GIMP makes working with a graphics editor a little easier, but using these tools to their full extent requires special skills.

Neural networks offer the most advanced way to change faces in photos. They can create incredibly realistic images and even generate new faces. However, access to these neural networks may be limited or paid, and using local versions requires significant computing power.

It is worth noting that each of these tools provides different solutions with different functionality. To make your choice easier, in this article we have collected the best options for programs, mobile applications and services based on artificial intelligence.

Midjourney

Midjourney is a popular neural network model designed for generating and editing images. This service has enormous capabilities that allow you to create graphics, photographs and designs at the professional level. At the same time, you do not need to study Photoshop or other graphic editors for months; you just need to correctly formulate a request to the neural network through a bot in Discord.

The presented neural network is capable of not only replacing a character’s face in a photograph, but doing it so well that it seems as if it is a real photograph. The neuron retains all the lighting, shadows and other details that were in the original image. The only problem is that to perform such manipulations you need to have a good understanding of Midjourney commands and scripts.

To force the neural network to replace people's faces in photographs, you need to connect an additional bot InsightFaceSwap. It's free, but you must have a Midjourney subscription to use it.

How to Replace a Face in a Photograph using Neural Networks (2)

Then you need to upload your photo and assign it a unique ID name. To do this, enter the /saveid command in the InsightFaceSwap message line and enter any memorable name for the sample. An area will appear where you can add a photo.

How to Replace a Face in a Photograph using Neural Networks (3)

Now you can use the uploaded photo of a person's face both as a replacement in the generated images and in other photographs. For the last option, enter the command /swapid in the message line of the InsightFaceSwap bot and add an advising snapshot. The idname contains the name of the identifier that you provided when uploading a photo of a person’s face.

How to Replace a Face in a Photograph using Neural Networks (4)

As an example of the work of InsightFaceSwap in the Midjourney bundle, let’s look at how the neural network coped with replacing the face of Jim Hendrix with Barack Obama.

How to Replace a Face in a Photograph using Neural Networks (5)

Of course, there is no limit to perfection, but for personal use the neural network provides good results.

Stable Diffusion

Stable Diffusion is also a neural network model, but open source. Although anyone can edit the code, this does not mean that using Stable Diffusion is free. To gain access to the latest versions of the model, you need to pay developers to use their API.

How to Replace a Face in a Photograph using Neural Networks (6)

The minimum top-up amount is $10, which provides 1000 credits. It turns out that for this money you can generate about 150 images using the latest version of SD3.

As an alternative, you can use the services of third-party developers who use the Stable Diffusion neural network as the basis for their services, for example, stablediffusionweb.com. For the same $10, you can generate or edit up to 2,000 images. Recently, the company developing the stablediffusionweb.com project launched a service for changing a person’s face in a photo together with the Stable Diffusion neural network at https://faceswap.so.

You do not need to register to use the power of artificial intelligence. The service provides 10 free attempts to change a face in a photo.

The user first uploads the photo where the person needs to be replaced, and then the source of the character. For example, let's try to replace the face of Leonid Brezhnev with Barack Obama.

How to Replace a Face in a Photograph using Neural Networks (7)

After a short wait, the service produced the following result.

How to Replace a Face in a Photograph using Neural Networks (8)

Here's a replacement of the baby's face with Obama's. As in the previous version, it is noticeable that the head is out of place.

How to Replace a Face in a Photograph using Neural Networks (9)

Despite the presence of some errors, the developers of faceswap.so managed to get good results using the Stable Diffusion neural network.

Adobe Firefly Photoshop

Despite Adobe's efforts, their Firefly neural network, which is built into Photoshop, is still inferior to Midjourney and Stable Diffusion in terms of the realism of replacing a face in a photo due to their longer development, but it can already boast of some results. Of course, you can’t do this without manual work, and you must, at a minimum, have the skills to interact with the Lasso tool.

It is noteworthy that Firefly offers two options for replacing a face: inserting a person into the generated space and, in fact, changing it on an existing photo. In the first case, you need to select the person, and then invert it to the entire photo. After this, just enter the Firefly promt in the Firefly dialog line.

How to Replace a Face in a Photograph using Neural Networks (10)
How to Replace a Face in a Photograph using Neural Networks (11)

To replace a person in an existing photo, you need to take a face and superimpose it on the photo. Next, use the Lasso tool to indicate the areas with which the neural network should work and start combining. In this case, there is no need to register any special information.

How to Replace a Face in a Photograph using Neural Networks (12)
How to Replace a Face in a Photograph using Neural Networks (13)

The presented option for replacing a face in Photoshop is more suitable for those who already use this program to solve certain problems in graphics or design. It is not suitable for one-time use, because for this you will need to: register on Adobe Cloud, subscribe or use the trial period, install the software and only then get started.

Artguru.ai

Another online service for replacing a person’s face in a photograph. It is difficult to establish which neural network model Artguru.ai uses, but the operating principle here is implemented similarly to the previous example. First, the photo where you want to replace the person is uploaded, and then the desired face.

How to Replace a Face in a Photograph using Neural Networks (14)
How to Replace a Face in a Photograph using Neural Networks (15)

Artguru.ai is a shareware service. The user is given only 8 attempts to replace a person's face in a photo.

Faceswap

Faceswap is open source software based on Google's Tensorflow neural network model. The program was specially developed by enthusiasts for the purpose of creating deepfakes, primarily videos. However, the presented solution can also be used to replace a person’s face in photographs.

A distinctive feature of Faceswap is that the user will have to independently train the neural network to search and identify faces. Here you won’t be able to simply take two photographs and replace the face on one. In order for the neural network to correctly perform this operation, it is necessary to upload at least 25 variants of the donor’s photo and the same number of images on the basis of which the deepfake will be created. The process of identifying, training and converting images requires significant computer resources and takes a lot of time.

How to Replace a Face in a Photograph using Neural Networks (16)

However, the ability to batch process photos and a large number of options make Faceswap a good choice when you need to process a large number of photos.

How to find the perfect face to replace in a photo

Although neural networks have facilitated the process of replacing a face in a photograph, the problem of finding the very photo that will become the donor remains. To do this, it is necessary that all photographs stored on the computer are well cataloged and sorted. However, it is difficult to maintain order when the photo archive contains pictures from different phones, cameras, and photos sent by friends via social networks and instant messengers.

The solution to this situation is the Tonfotos program. This is a special software that collects all the photos on your computer into a single database and sorts them in chronological order, by location or pre-created albums. There is a function for identifying and recognizing faces. With its help, you can quickly find a suitable photo, which you can later use to create deepfakes. To do this, you only need to specify the person’s name in the photo once, and then the program will automatically find the rest of the photos on the computer with this person.

How to Replace a Face in a Photograph using Neural Networks (17)

Summary

Neural networks have reached a high level in creating and processing images, including replacing people's faces in photographs. With their help, you can get a truly high-quality and realistic result that will satisfy the majority of household consumers. And professionals can make the work easier and faster, because all that remains is to slightly correct the resulting image.

How to Replace a Face in a Photograph using Neural Networks (2024)

References

Top Articles
Latest Posts
Article information

Author: Francesca Jacobs Ret

Last Updated:

Views: 6212

Rating: 4.8 / 5 (68 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Francesca Jacobs Ret

Birthday: 1996-12-09

Address: Apt. 141 1406 Mitch Summit, New Teganshire, UT 82655-0699

Phone: +2296092334654

Job: Technology Architect

Hobby: Snowboarding, Scouting, Foreign language learning, Dowsing, Baton twirling, Sculpting, Cabaret

Introduction: My name is Francesca Jacobs Ret, I am a innocent, super, beautiful, charming, lucky, gentle, clever person who loves writing and wants to share my knowledge and understanding with you.