Photoshopで顔交換!stable diffusion の Reactor FaceSwap APIへ接続する UXPプラグイン作っています

Adobe Photoshopで簡単に顔交換を実現する「Photoshop FaceSwap UXPプラグイン」を開発しています。このプラグインを使えば、画像の顔をスムーズに交換でき、クリエイティブな画像編集がもっと楽しくなります。本記事では、プラグインの概要や機能、使い方を詳しくご紹介します。

I developing the “Photoshop FaceSwap UXP Plugin” to easily swap faces in Adobe Photoshop. With this plugin, you can smoothly swap faces in images, making creative image editing more fun. In this article, I will introduce the overview of the plugin, its functions, and how to use it in detail.

プラグインの概要

Photoshop FaceSwap UXPプラグインは、Adobe Photoshop 2021以降で動作するUXPベースのプラグインです。カレントレイヤーの顔画像と、プラグイン内で選択した別の画像の顔を、Stable diffusion extension Reactor で交換する機能を提供します。
直感的な操作で、初心者からプロまで幅広く活用できるツールを目指しています。

Plugin Overview

The Photoshop FaceSwap UXP Plugin is a UXP-based plugin that runs on Adobe Photoshop 2021 and later. It provides the ability to swap the face image of the current layer with the face of another image selected within the plugin using the Stable diffusion extension Reactor.
We aim to create a tool that can be used by a wide range of users, from beginners to professionals, with intuitive operation.

現在の開発状況

2025-04-22 update

現時点では、以下の機能が実装されています:

  • プラグインパネルでの選択画像のプレビュー表示
  • 顔交換モデルの選択機能

ただし、以下の課題が残っています:

  • RGB8形式の画像に限定
  • カラープロファイルがない画像は処理不可
  • 最下位レイヤーのみ処理可能

今後、これらの課題を解決し、より柔軟な処理を実現する予定です。

Current development status

2025-04-22 update

At present, the following features are implemented:

Preview display of selected image in plugin panel

Face swap model selection function

However, the following issues remain:

Limited to RGB8 format images

Images without a color profile cannot be processed

Only the lowest layer can be processed

We plan to solve these issues in the future and achieve more flexible processing.

主な機能

のプラグインは、以下の機能を提供します:

  • 単一画像の選択: 顔交換に使用するソース画像を簡単に選択。
  • プレビュー表示: 選択した画像をプラグイン内で確認可能。
  • 顔交換処理: カレントレイヤーと選択画像の顔をスワップ。
  • 結果のレイヤー挿入: 処理結果を新しいレイヤーとして追加。

Main Features

The plugin provides the following features:

Single Image Selection: Easily select the source image you want to use for face swap.

Preview: Check the selected image within the plugin.

Face Swap Process: Swap the faces of the current layer and the selected image.

Insert Result Layer: Add the processing result as a new layer.

動作環境

プラグインを使用するには、以下の環境が必要です:

  • Adobe Photoshop 2021以降
  • UXP対応環境

Operating environment

To use the plugin, you need the following:

Adobe Photoshop 2021 or later

UXP compatible environment

インストール手順

  1. GitHubリポジトリ develop branch(こちら)からプラグインをクローンまたはダウンロードします。
  2. Adobe UXP Developer Toolを起動し、プラグインをロードします。
  3. Photoshopでプラグインを有効化します

Installation Instructions

Clone or download the plugin from the GitHub repository here. develop branch

Launch Adobe UXP Developer Tool and load the plugin.

Activate the plugin in Photoshop.

使い方

以下の手順でプラグインを使用できます:

  • Photoshopでプラグインを起動。「画像選択」ボタンをクリックして、顔交換に使用するソース画像を選択。
  • 選択した画像がプレビューエリアに表示されることを確認。
  • Photoshopで顔交換したい画像とレイヤーを開く。
  • 「FaceSwap」ボタンをクリックして処理を実行。
  • 処理結果が新しいレイヤーとして追加される。

技術的なポイント

UXP内から直接fetchしています、中間サーバーはありません。
このプラグインは、jsとAdobe UXPを活用して開発されています。
顔交換処理は、ローカルで動作するStablediffusion の Reactor Face Swap APIに依存しており、以下のようなリクエストを送信します。

How to use

The plugin can be used in the following steps:

  • Launch the plugin in Photoshop. Click the “Select Image” button to select the source image to be used for face swap.
  • Confirm that the selected image is displayed in the preview area.
  • Open the image and layer you want to swap faces with in Photoshop.
  • Click the “FaceSwap” button to execute the process.
  • The processing result is added as a new layer.

Technical points

Fetching is done directly from within UXP, there is no intermediate server.
This plugin is developed using js and Adobe UXP.
The face swap process relies on Stablediffusion’s Reactor Face Swap API running locally, and sends the following request:

from https://github.com/Gourieff/sd-webui-reactor-sfw/blob/main/API.md

curl -X POST \
	'http://127.0.0.1:7860/reactor/image' \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '{
    "source_image": "data:image/png;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAABQAAD/7g...",
    "target_image": "data:image/png;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAABCAAD/7g...",
    "source_faces_index": [0],
    "face_index": [0],
    "upscaler": "4x_NMKD-Siax_200k",
    "scale": 2,
    "upscale_visibility": 1,
    "face_restorer": "CodeFormer",
    "restorer_visibility": 1,
    "restore_first": 1,
    "model": "inswapper_128.onnx",
    "gender_source": 0,
    "gender_target": 0,
    "save_to_file": 0,
    "result_file_path": "",
    "device": "CUDA",
    "mask_face": 1,
    "select_source": 1,
    "face_model": "elena.safetensors",
    "source_folder": "C:/faces",
    "random_image": 1,
    "upscale_force": 1
	}'

今後の展望

現在は開発中のプラグインですが、以下の改善を計画しています:

  • 複数レイヤーやカラープロファイルのサポート
  • 処理速度の最適化
  • UI/UXの向上

Future Outlook

This plugin is currently under development, but we plan to make the following improvements:

  • Support for multiple layers and color profiles
  • Optimized processing speed
  • Improved UI/UX

まとめ

Photoshop FaceSwap UXPプラグインは、Photoshopでの顔交換を簡単かつ効率的に行えるツールです。現在のバージョンでは基本的な機能を提供していますが、今後のアップデートでさらに使いやすくなる予定です。ぜひ試してみて、GitHubでフィードバックを共有してください!

Summary

The Photoshop FaceSwap UXP plugin is a simple and efficient tool for face swapping in Photoshop. The current version provides basic functionality, but future updates will make it even easier to use. Give it a try and share your feedback on GitHub!

GitHubリポジトリはこちら

ご相談・お問合せ

お気軽にどうぞ。