Diffusers documentation

JoyAI-Image-Edit-Plus

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.42.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

JoyAI-Image-Edit-Plus

JoyAI-Imageは、画像理解、テキストからの画像生成、指示に基づく画像編集のための統合型マルチモーダル基盤モデルです。8Bのマルチモーダル大規模言語モデル(MLLM)と16Bのマルチモーダル拡散トランスフォーマー(MMDiT)を組み合わせています。

JoyAI-Image-Edit-Plus は、複数の参照画像とテキスト指示を受け取り、その指示に従って参照画像の要素を組み合わせることで新しい画像を生成する、マルチ画像の指示ガイド型編集モデルです。1 サンプルあたり 1〜5 枚の参照画像に対応しています。

モデル説明ダウンロード
JoyAI-Image-Edit-Plus複数の参照からの要素合成を用いた、複数画像の指示ガイド付き編集Hugging Face
import torch
from PIL import Image
from diffusers import JoyImageEditPlusPipeline

pipeline = JoyImageEditPlusPipeline.from_pretrained(
    "jdopensource/JoyAI-Image-Edit-Plus-Diffusers", dtype=torch.bfloat16
)
pipeline.to("cuda")  # or "mps", "xpu", "cpu"

images = [
    Image.open("reference_0.png").convert("RGB"),
    Image.open("reference_1.png").convert("RGB"),
]

target_h, target_w = pipeline.image_processor.get_default_height_width(images[-1])

output = pipeline(
    images=images,
    prompt="Combine the person from the second image with the scene from the first image.",
    negative_prompt="low quality, blurry, deformed",
    height=target_h,
    width=target_w,
    num_inference_steps=30,
    guidance_scale=4.0,
    generator=torch.Generator("cuda").manual_seed(42),
).images[0]
output.save("joyimage_edit_plus_output.png")

JoyImageEditPlusPipeline

class diffusers.JoyImageEditPlusPipeline

< >

( scheduler: FlowMatchEulerDiscreteSchedulervae: AutoencoderKLWantext_encoder: Qwen3VLForConditionalGenerationtokenizer: Qwen2Tokenizertransformer: JoyImageEditPlusTransformer3DModelprocessor: Qwen3VLProcessortext_token_max_length: int = 2048 )

パラメータ

  • scheduler (FlowMatchEulerDiscreteScheduler) — transformer と組み合わせて、エンコードされた画像の潜在変数からノイズを除去するために使用するスケジューラ。
  • vae (AutoencoderKLWan) — 画像を潜在表現にエンコードし、潜在表現からデコードするための変分オートエンコーダ (VAE) モデル。
  • text_encoder (Qwen3VLForConditionalGeneration) — インライン画像理解を伴うプロンプトエンコーディング用のマルチモーダルテキストエンコーダー。
  • tokenizer (Qwen2Tokenizer) — テキスト処理用のトークナイザー。
  • transformer (JoyImageEditPlusTransformer3DModel) — エンコードされた画像潜在変数をデノイズするための、条件付き Transformer (MMDiT) アーキテクチャ。
  • processor (Qwen3VLProcessor) — マルチモーダル入力(テキスト + 画像)用のプロセッサ。
  • text_token_max_length (int、デフォルトは2048) — テキストエンコーディングにおける最大トークン長。

JoyImage Edit Plus を使用した、複数画像の指示ガイド付き編集のための Diffusion パイプライン。

異なる解像度を有する複数の参照画像をサポートします。各参照画像は独立してVAEエンコードおよびパッチ化され、その後、ターゲットノイズパッチと連結されて共同デノイジングが行われます。

__call__

< >

( images: list[PIL.Image.Image] | list[list[PIL.Image.Image]] | None = Noneprompt: str | list[str] = Noneheight: int | None = Nonewidth: int | None = Nonenum_inference_steps: int = 30timesteps: list = Nonesigmas: list = Noneguidance_scale: float = 4.0negative_prompt: str | list[str] | None = Nonegenerator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = Noneprompt_embeds: typing.Optional[torch.Tensor] = Noneprompt_embeds_mask: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds_mask: typing.Optional[torch.Tensor] = Noneoutput_type: str | None = 'pil'return_dict: bool = Truecallback_on_step_end: typing.Union[typing.Callable[[int, int, dict], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = Nonecallback_on_step_end_tensor_inputs: list = ['latents']max_sequence_length: int = 4096 ) → JoyImageEditPlusPipelineOutput or tuple

パラメータ

  • images (list[Image.Image] または list[list[Image.Image]]、任意) — 編集用の参照画像です。各画像の解像度は異なっていても構いません。フラットなリストが指定された場合、複数の参照画像を持つ1つのサンプルとして扱われます。
  • prompt (str または list[str]、任意) — 画像生成をガイドするためのプロンプトです。定義されていない場合、代わりに prompt_embeds を渡す必要があります。
  • height (int, 任意) — 生成される画像のピクセル単位の縦幅。None の場合、最後の参照画像から決定されます。
  • width (int, 任意) — 生成される画像の幅(ピクセル単位)。None の場合、最後の参照画像から決定されます。
  • num_inference_steps (int、任意、デフォルトは 30) — デノイジングのステップ数です。ステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。
  • timesteps (list[int]、任意) — ノイズ除去プロセスに使用するカスタムタイムステップ。未定義の場合、等間隔が使用されます。
  • sigmas (list[float], 任意) — デノイジングプロセスに使用するカスタムシグマ。
  • guidance_scale (float、任意、デフォルトは 4.0) — Classifier-free guidance のスケールです。値を大きくすると、prompt に沿った画像を生成する傾向が強まりますが、画像の品質が低下する可能性があります。
  • negative_prompt (str または list[str]、省略可) — 画像生成をガイドしないプロンプトです。定義されていない場合、classifier-free guidance には空のプロンプトが使用されます。
  • generator (torch.Generator または list[torch.Generator]、省略可) — 生成を決定論的にするためのtorch ジェネレーター1つまたはリスト。
  • latents (torch.Tensor, 任意) — 画像生成の入力として使用する、事前生成されたノイズ付き潜在変数。
  • prompt_embeds (torch.Tensor、任意) — 事前に生成されたテキスト埋め込み。テキスト入力の調整を簡単に実行できます。
  • prompt_embeds_mask (torch.Tensor, 任意) — 事前生成されたテキスト埋め込み用のアテンションマスク。
  • negative_prompt_embeds (torch.Tensor, 任意) — 事前に生成されたネガティブテキストの埋め込みです。
  • negative_prompt_embeds_mask (torch.Tensor, 任意) — 事前生成されたネガティブテキスト埋め込み用のアテンションマスク。
  • output_type (str, 任意、デフォルトは "pil") — 生成された画像の出力形式です。"pil" (PIL.Image.Image)、"np" (np.ndarray)、"pt" (torch.Tensor)、または生の潜在出力の "latent" から選択します。
  • return_dict (bool、任意、デフォルトは True) — True の場合、通常のタプルではなく JoyImageEditPlusPipelineOutput を返します。
  • callback_on_step_end (Callable, 省略可) — デノイジングステップの終了時に呼び出される関数です。引数として、パイプライン、ステップインデックス、タイムステップ、およびコールバックのテンソル入力を含む辞書を受け取ります。
  • callback_on_step_end_tensor_inputs (list[str]、任意、デフォルトは ["latents"]) — callback_on_step_end 関数に渡すテンソル入力のリストです。
  • max_sequence_length (int、任意、デフォルトは 4096) — テキストエンコーダーの最大シーケンス長。

戻り値

JoyImageEditPlusPipelineOutput または tuple

return_dict が True の場合、JoyImageEditPlusPipelineOutput が返され、それ以外の場合は、最初の要素が生成された画像のリストである tuple が返されます。

生成用のパイプラインを呼び出したときに実行される関数。

例:

>>> import torch
>>> from diffusers import JoyImageEditPlusPipeline
>>> from diffusers.utils import load_image

>>> model_id = "jdopensource/JoyAI-Image-Edit-Plus-Diffusers"
>>> pipe = JoyImageEditPlusPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")

>>> images = [
...     load_image("dog.png"),
...     load_image("person.png"),
... ]
>>> output = pipe(
...     images=images,
...     prompt="Let the person lovingly play with the dog.",
...     height=1024,
...     width=1024,
...     num_inference_steps=30,
...     guidance_scale=4.0,
...     generator=torch.manual_seed(42),
... )
>>> output.images[0].save("output.png")

encode_prompt_multiple_images

< >

( prompt: str | list[str]device: typing.Optional[torch.device] = Noneimages: list[PIL.Image.Image] | None = Nonemax_sequence_length: int | None = None )

Qwen3-VL プロセッサーを使用して、インラインの<image>トークンを含むプロンプトをエンコードします。

prepare_latents

< >

( batch_size: intnum_channels_latents: intheight: intwidth: intdtype: dtypedevice: devicegenerator: typing.Union[torch.Generator, list[torch.Generator], NoneType]reference_images: list[list[PIL.Image.Image]] | None = Nonelatents: typing.Optional[torch.Tensor] = None ) → padded_latents

パラメータ

  • latents — ターゲットスロット用の事前計算済みノイズ(任意)。形状は (B, C, 1, H', W') で、H' と W' は潜在空間の次元です。None の場合、ランダムなノイズがサンプリングされます。

戻り値

padded_latents

[B, max_patches, C, pt, ph, pw] target_mask: [B, max_patches] (ターゲットのパッチは True) shape_list: 各コンポーネントの (t, h, w) タプルのサンプルごとのリスト

ターゲットノイズと参照画像の潜在変数を含む、6次元のパディング済み潜在テンソルを準備します。

JoyImageEditPlusPipelineOutput

class diffusers.JoyImageEditPlusPipelineOutput

< >

( images: typing.Union[typing.List[PIL.Image.Image], numpy.ndarray] )

JoyImage Edit Plus マルチ画像編集パイプライン用の出力クラスです。

Update on GitHub