Run PhotoMaker with an API

TencentARC PhotoMaker is an AI tool that allows you to:

  • make realistic photos of real people instantly (without needing to train a LoRA or fine-tune a model)
  • maintain likenesses from images even in different styles and poses
  • generate images of people with a strong likeness using any SDXL base model or fine-tune

You can run PhotoMaker on Replicate. This is a photorealistic model that uses RealVisXL V3.0 as the SDXL base weights.

There’s also a styled PhotoMaker that uses SDXL Unstable Diffusers to make 3D renders of people.

In this example we show an input photo of Yann LeCun, a famous computer scientist, and we generate a new photo of him receiving a Nobel Prize.

You can see how well PhotoMaker maintains the likeness of the input from a single image.

A close-up photo of a scientist img receiving the Nobel Prize

PhotoMaker takes 1 or more images as input and generates a new image based on a prompt. To get the best likeness in your results we recommend using 4 input images of the same person.

Your prompt must include the trigger word to activate PhotoMaker. In all of Replicate’s models the trigger word is img:

A close-up photo of a scientist img receiving the Nobel Prize

We recommend 20 to 30 steps with a guidance scale of 5.

As PhotoMaker uses SDXL, you can use prompt, negative prompt, number of steps and guidance scale as you would with Stable Diffusion. Read our Stable Diffusion guide for more tips.

All models on Replicate come with a production-ready API. You can use our official Python, Node.js, Swift, Elixir and Go clients.

We’ll use the Python client in this example, and run the prediction we showed above.

You’ll need to sign up for Replicate, then you can find your API token on your account page.

Install Replicate’s Python client library:

pip install replicate

Set the REPLICATE_API_TOKEN environment variable:

export REPLICATE_API_TOKEN=r8-*********************************

Import the client and run the PhotoMaker model:

import replicate

output =
        "prompt": "A close-up photo of a scientist img receiving the Nobel Prize",
        "num_steps": 30,
        "style_name": "Photographic (Default)",
        "input_image": "",
        "num_outputs": 1,
        "guidance_scale": 5,
        "style_strength_ratio": 20

Not only can you use photographic inputs of people, but you can pass in paintings, photos of sculptures, 3D renders and more. You can bring historic figures to life, or see how video game characters might look in the real world.

If you ask for multiple people, or combine different people, you’ll get weird but interesting results.

Here is Isaac Newton beneath an apple tree:

A photo of a man img sitting beneath an apple tree

You can use PhotoMaker with ComfyUI, and it’s supported in our run any ComfyUI workflow model.

If you’re familiar with ComfyUI, you can use the PhotoMaker nodes to combine the tool with other models, such as IPAdapters and LoRAs. You can also pick and choose from all the SDXL base weights available.

In this example we used the ComfyUI PhotoMaker workflow to turn photos of a Julius Caesar sculpture into a photo of a real person:

[JSON code not shown]