Diffusers documentation

Bria Fibo Edit

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Bria Fibo Edit

Fibo Editは8Bパラメータの画像から画像へのモデルであり、ソース画像と組み合わせたJSON入力に対して動作する新しい構造化制御のパラダイムを導入し、決定論的かつ再現可能な編集ワークフローを可能にします。 細粒度の精度を実現するネイティブなマスキング機能を備え、単純なプロンプトベースの拡散を超えて、本番環境向けに最適化された明示的かつ解釈可能な制御を提供します。 軽量なアーキテクチャは深いカスタマイズを目的として設計されており、研究者がドメイン固有のタスク向けに特化した「Edit」モデルを構築できる一方で、トップクラスの美的品質を実現します。

詳細については、Bria Fibo Edit の Hugging Face ページを参照してください。蒸留済みチェックポイントは Fibo-Edit-1.5-turbo で利用可能です。

使用方法

このモデルはゲート付きのため、diffusers で使用する前に、まず Bria Fibo Edit の Hugging Face ページ にアクセスしてフォームに記入し、ゲートの承認を行う必要があります。承認が完了したら、システムがゲートの承認済みであることを認識できるよう、ログインしてください。

以下のコマンドを使用してログインします:

hf auth login

BriaFiboEditPipeline

class diffusers.BriaFiboEditPipeline

< >

( transformer: BriaFiboTransformer2DModelscheduler: typing.Union[diffusers.schedulers.scheduling_flow_match_euler_discrete.FlowMatchEulerDiscreteScheduler, diffusers.schedulers.scheduling_utils.KarrasDiffusionSchedulers]vae: AutoencoderKLWantext_encoder: SmolLM3ForCausalLMtokenizer: AutoTokenizer )

パラメータ

  • transformer (BriaFiboTransformer2DModel) — 2次元拡散モデリング用のtransformerモデルです。
  • scheduler (FlowMatchEulerDiscreteScheduler または KarrasDiffusionSchedulers) — transformer と組み合わせて、エンコードされた潜在変数からノイズを除去するために使用するスケジューラー。
  • vae (AutoencoderKLWan) — 画像を潜在表現にエンコードし、潜在表現からデコードするための変分オートエンコーダ。
  • text_encoder (SmolLM3ForCausalLM) — 入力プロンプトを処理するためのテキストエンコーダー。
  • tokenizer (AutoTokenizer) — text_encoder に入力するテキストプロンプトを処理するために使用される Tokenizer。

__call__

< >

( prompt: typing.Union[str, typing.List[str]] = Noneimage: typing.Union[PIL.Image.Image, typing.List[PIL.Image.Image], NoneType] = Nonemask: typing.Union[torch.FloatTensor, PIL.Image.Image, typing.List[PIL.Image.Image], typing.List[torch.FloatTensor], numpy.ndarray, typing.List[numpy.ndarray], NoneType] = Noneheight: int | None = Nonewidth: int | None = Nonenum_inference_steps: int = 30timesteps: typing.List[int] = Noneseed: int | None = Noneguidance_scale: float = 5negative_prompt: typing.Union[str, typing.List[str], NoneType] = Nonenum_images_per_prompt: typing.Optional[int] = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.FloatTensor] = Noneoutput_type: str = 'pil'return_dict: bool = Truejoint_attention_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = Nonecallback_on_step_end: typing.Optional[typing.Callable[[int, int, typing.Dict], NoneType]] = Nonecallback_on_step_end_tensor_inputs: typing.List[str] = ['latents']max_sequence_length: int = 3000do_patching = False_auto_resize: bool = True ) → ~pipelines.flux.BriaFiboPipelineOutput or tuple

パラメータ

  • prompt (str または List[str]) — 画像生成を導くプロンプト、またはプロンプトのリスト。
  • image (PIL.Image.Image または List[PIL.Image.Image]、任意) — 画像生成をガイドするための1枚以上の参照画像です。リストはバッチではなく、複数の参照として解釈されます。各参照画像は、それぞれのアスペクト比でVAEエンコードされ、独自のRoPE時間平面1、2、…に配置されます。定義されていない場合、パイプラインはゼロから画像を生成します。
  • mask (PipelineMaskInput, 任意) — image を編集する領域を定義する任意のマスクです。マスクで覆われたピクセルは再生成され、画像の残りは保持されます。
  • height (int、任意、デフォルトは self.unet.config.sample_size * self.vae_scale_factor) — 生成される画像のピクセル単位の縦幅です。最適な結果を得るため、デフォルトでは 1024 に設定されています。
  • width (int、任意、デフォルトは self.unet.config.sample_size * self.vae_scale_factor) — 生成される画像の幅(ピクセル単位)です。最適な結果を得るため、デフォルトでは 1024 に設定されています。
  • num_inference_steps (int、任意、デフォルト値は 30)— デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。
  • seed (int, 任意) — 生成を決定論的にするために使用されるシード。
  • timesteps (List[int], 任意) — timesteps 引数をサポートするスケジューラーの set_timesteps メソッドで、デノイジングプロセスに使用するカスタムタイムステップを指定します。定義されていない場合、num_inference_steps が渡された際のデフォルトの動作が使用されます。降順で指定する必要があります。
  • guidance_scale (float、任意、デフォルト値は 5.0) — Classifier-Free Diffusion Guidance で定義されているガイダンススケールです。guidance_scale は、Imagen Paper の数式 2 の w として定義されています。guidance_scale > 1 を設定することで、ガイダンススケールが有効になります。ガイダンススケールを高くすると、prompt のテキストと密接に関連する画像の生成が促されますが、通常は画像の品質が低下する傾向があります。
  • negative_prompt (str または List[str]、任意) — 画像生成をガイドしないプロンプトです。ガイダンスを使用していない場合は無視されます(guidance_scale が 1 未満の場合は無視されます)。
  • num_images_per_prompt (int、任意、デフォルトは 1) — プロンプトごとに生成する画像の数。
  • generator (torch.Generator または List[torch.Generator]、任意) — 生成を決定論的にするためのtorch ジェネレーター1つまたはリスト。
  • latents (torch.FloatTensor, 任意) — 画像生成の入力として使用する、ガウス分布からサンプリングされた事前生成されたノイズ付き潜変数です。異なるプロンプトで同じ生成を調整するために使用できます。指定されない場合、指定されたランダムgeneratorを使用してサンプリングを行い、潜変数テンソルが生成されます。
  • output_type (str、任意、デフォルトは "pil") — 画像生成の出力形式です。PIL: PIL.Image.Image または np.array から選択します。
  • return_dict (bool、省略可能、デフォルトは True) — ~pipelines.stable_diffusion_xl.StableDiffusionXLPipelineOutput を返すかどうか。プレーンなタプルを返すこともできます。
  • joint_attention_kwargs (dict、省略可) — 指定された場合、diffusers.models.attention_processor で定義されている self.processor 配下の AttentionProcessor に渡される kwargs の辞書です。
  • callback_on_step_end (Callable, 省略可) — 推論中の各デノイジングステップの終了時に呼び出される関数です。この関数は、以下の引数とともに呼び出されます: callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)。 callback_kwargs には、callback_on_step_end_tensor_inputs で指定されたすべてのテンソルのリストが含まれます。
  • callback_on_step_end_tensor_inputs (List, 任意) — callback_on_step_end 関数へのテンソル入力の一覧です。リストで指定されたテンソルは、callback_kwargs 引数として渡されます。パイプラインクラスの ._callback_tensor_inputs 属性にリストされている変数のみを含めることができます。
  • max_sequence_length (int、デフォルト値は 3000)— prompt に使用する最大シーケンス長。
  • do_patching (bool、省略可能、デフォルトはFalse) — パッチングを使用するかどうか。
  • _auto_resize (bool、任意、デフォルトはTrue) — デフォルトの出力解像度(最初の参照画像から取得)を、推奨される解像度にスナップするかどうかを指定します。

戻り値

~pipelines.flux.BriaFiboPipelineOutput または tuple

return_dictがTrueの場合、~pipelines.flux.BriaFiboPipelineOutput、それ以外の場合はtupleを返します。タプルを返す場合、最初の要素は生成された画像のリストです。

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

例:

import torch
from PIL import Image

from diffusers import BriaFiboEditPipeline
from diffusers.modular_pipelines import ModularPipelineBlocks

# This prompt-to-JSON block calls Gemini and needs GEMINI_API_KEY in the environment.
vlm_pipe = ModularPipelineBlocks.from_pretrained("briaai/FIBO-edit-gemini-prompt-to-JSON", trust_remote_code=True)
vlm_pipe = vlm_pipe.init_pipeline()

pipe = BriaFiboEditPipeline.from_pretrained(
    "briaai/Fibo-Edit-1.5-base",
    torch_dtype=torch.bfloat16,
)
pipe.to("cuda")

image = Image.open("owl.png")
json_prompt = vlm_pipe(image=image, prompt="Make the owl into a cat").values["json_prompt"]

result = pipe(prompt=json_prompt, image=image, num_inference_steps=30, guidance_scale=5)

# Multiple reference images: pass a list. Each reference conditions the edit at its
# own aspect ratio; the output resolution follows the first reference.
owl, forest = Image.open("owl.png"), Image.open("forest.png")
json_prompt = vlm_pipe(
    image=[owl, forest], prompt="Place the owl from the first image in the forest from the second image"
).values["json_prompt"]
result = pipe(
    prompt=json_prompt,
    image=[owl, forest],
    num_inference_steps=30,
    guidance_scale=5,
)

# The distilled Turbo checkpoint edits in 4 steps without classifier-free guidance.
pipe = BriaFiboEditPipeline.from_pretrained("briaai/Fibo-Edit-1.5-turbo", torch_dtype=torch.bfloat16)
pipe.to("cuda")
result = pipe(prompt=json_prompt, image=[owl, forest], num_inference_steps=4, guidance_scale=1)

encode_prompt

< >

( prompt: typing.Union[str, typing.List[str]]device: typing.Optional[torch.device] = Nonenum_images_per_prompt: int = 1guidance_scale: float = 5negative_prompt: typing.Union[str, typing.List[str], NoneType] = Nonemax_sequence_length: int = 3000lora_scale: bool | None = None )

パラメータ

  • prompt (str または List[str]、省略可) — エンコードするプロンプト
  • device — (torch.device): torch デバイス
  • num_images_per_prompt (int) — 1つのプロンプトに対して生成する画像の数
  • guidance_scale (float) — classifier free guidance のガイダンススケール。
  • negative_prompt (str または List[str]、任意) — 画像生成をガイドしないプロンプトです。ガイダンスを使用していない場合は無視されます(guidance_scale が 1 未満の場合は無視されます)。

prepare_reference_latents

< >

( image: Imagenum_channels_latents: intdtype: dtypedevice: devicedo_patching: bool = Falsereference_index: int = 1 )

VAEエンコードにより、PIL参照画像をその元のサイズでエンコードし、編集コンテキストのトークンストリームとしてパックします。

Update on GitHub