Buckets:

mishig's picture
|
download
raw
11.1 kB
# Bria Fibo
テキストから画像を生成するモデルは想像力を身につけましたが、制御はまだできていません。FIBOはその状況を変えます。
FIBO は、1,000 語以上の構造化 JSON キャプションで学習されており、照明、構図、色、カメラ設定などの異なる視覚パラメータを理解・制御するように設計されています。これにより、正確で再現可能な出力が実現できます。
わずか80億パラメータながら、FIBOは画質、プロンプトへの忠実度、プロフェッショナルなコントロールにおいて新たなレベルを実現します。
FIBO is trained exclusively on a structured prompt and will not work with freeform text prompts. you can use the [FIBO-VLM-prompt-to-JSON](https://huggingface.co/briaai/FIBO-VLM-prompt-to-JSON) model or the [FIBO-gemini-prompt-to-JSON](https://huggingface.co/briaai/FIBO-gemini-prompt-to-JSON) to convert your freeform text prompt to a structured JSON prompt.
> [!NOTE]
> FIBOでは、フリーフォームのテキストプロンプトを直接使用すると最適な結果が得られないため、避けてください。
詳細については、Bria FiboのHugging Face [ページ](https://huggingface.co/briaai/FIBO)を参照してください。
## 使用方法
_このモデルはゲート付き(アクセス制限付き)のため、diffusers で使用する前に、まず [Bria Fibo の Hugging Face ページ](https://huggingface.co/briaai/FIBO) にアクセスし、フォームに記入してゲートの承認を行う必要があります。承認が完了したら、システムがゲートの承認済みであることを認識できるよう、ログインしてください。_
以下のコマンドを使用してログインします:
```bash
hf auth login
```
## BriaFiboPipeline[[diffusers.BriaFiboPipeline]]
#### diffusers.BriaFiboPipeline[[diffusers.BriaFiboPipeline]]
```python
diffusers.BriaFiboPipeline(transformer: BriaFiboTransformer2DModel, scheduler: diffusers.schedulers.scheduling_flow_match_euler_discrete.FlowMatchEulerDiscreteScheduler | diffusers.schedulers.scheduling_utils.KarrasDiffusionSchedulers, vae: AutoencoderKLWan, text_encoder: SmolLM3ForCausalLM, tokenizer: AutoTokenizer)
```
[ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/bria_fibo/pipeline_bria_fibo.py#L76)
**パラメータ:**
transformer (`BriaFiboTransformer2DModel`) : 2次元拡散モデリング用のtransformerモデルです。
scheduler (`FlowMatchEulerDiscreteScheduler` または `KarrasDiffusionSchedulers`) : `transformer` と組み合わせて、エンコードされた潜在変数のノイズ除去に使用するスケジューラー。
vae (`AutoencoderKLWan`) : 画像を潜在表現にエンコードし、潜在表現からデコードするための変分オートエンコーダー。
text_encoder (`SmolLM3ForCausalLM`) : 入力プロンプトを処理するためのテキストエンコーダー。
tokenizer (`AutoTokenizer`) : text_encoder に入力するテキストプロンプトを処理するために使用される Tokenizer。
#### __call__[[diffusers.BriaFiboPipeline.__call__]]
```python
__call__(prompt: str | list[str] = None, height: int | None = None, width: int | None = None, num_inference_steps: int = 30, timesteps: list[int] = None, guidance_scale: float = 5, negative_prompt: str | list[str] | None = None, num_images_per_prompt: int | None = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.FloatTensor] = None, output_type: str | None = 'pil', return_dict: bool = True, joint_attention_kwargs: dict[str, typing.Any] | None = None, callback_on_step_end: typing.Optional[typing.Callable[[int, int], NoneType]] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 3000, do_patching = False)
```
[ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/bria_fibo/pipeline_bria_fibo.py#L435)
**パラメータ:**
prompt (`str` または `list[str]`) : 画像生成をガイドするためのプロンプト、またはプロンプトのリスト。
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`、*任意*、デフォルト値は 50) : デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。
timesteps (`list[int]`、*任意*) : `set_timesteps` メソッドで `timesteps` 引数をサポートするスケジューラーにおいて、デノイジングプロセスに使用するカスタムタイムステップ。`num_inference_steps` が渡された場合のデフォルトの動作が使用されます。降順で指定する必要があります。
guidance_scale (`float`、*任意*、デフォルト値は 5.0) : [Classifier-Free Diffusion Guidance](https://huggingface.co/papers/2207.12598)で定義されているガイダンススケールです。`guidance_scale` は、[Imagen Paper](https://huggingface.co/papers/2205.11487)の式 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 ジェネレーター](https://pytorch.org/docs/stable/generated/torch.Generator.html) 1 つまたはそのリスト。
latents (`torch.FloatTensor`, *任意*) : イメージ生成の入力として使用する、ガウス分布からサンプリングされた事前生成されたノイジー・ラテンツ。異なるプロンプトで同じ生成を調整するために使用できます。指定されない場合、指定されたランダムな`generator`を使用してサンプリングを行い、ラテンツのテンソルが生成されます。
output_type (`str`、*任意*、デフォルトは `"pil"`) : 生成画像の出力形式。[PIL](https://pillow.readthedocs.io/en/stable/)(`PIL.Image.Image`)または `np.array` から選択します。
return_dict (`bool`、*任意*、デフォルトは`True`) : プレーンなタプルではなく`~pipelines.stable_diffusion_xl.StableDiffusionXLPipelineOutput`を返すかどうか。
joint_attention_kwargs (`dict`, *任意*) : 指定された場合、[diffusers.models.attention_processor](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py) の `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`) : パッチングを使用するかどうか。
**戻り値:** `~pipelines.flux.BriaFiboPipelineOutput` または `tuple`
`return_dict` が True の場合は `~pipelines.flux.BriaFiboPipelineOutput`、それ以外の場合は `tuple` を返します。tuple を返す場合、最初の要素は生成された画像のリストです。
生成用のパイプラインを呼び出したときに実行される関数。
例:
```python
import torch
from diffusers import BriaFiboPipeline
from diffusers.modular_pipelines import ModularPipeline
torch.set_grad_enabled(False)
vlm_pipe = ModularPipeline.from_pretrained("briaai/FIBO-VLM-prompt-to-JSON", trust_remote_code=True)
pipe = BriaFiboPipeline.from_pretrained(
"briaai/FIBO",
trust_remote_code=True,
torch_dtype=torch.bfloat16,
)
pipe.enable_model_cpu_offload()
with torch.inference_mode():
# 1. Create a prompt to generate an initial image
output = vlm_pipe(prompt="a beautiful dog")
json_prompt_generate = output.values["json_prompt"]
# Generate the image from the structured json prompt
results_generate = pipe(prompt=json_prompt_generate, num_inference_steps=50, guidance_scale=5)
results_generate.images[0].save("image_generate.png")
```
#### encode_prompt[[diffusers.BriaFiboPipeline.encode_prompt]]
```python
encode_prompt(prompt: str | list[str], device: typing.Optional[torch.device] = None, num_images_per_prompt: int = 1, guidance_scale: float = 5, negative_prompt: str | list[str] | None = None, max_sequence_length: int = 3000, lora_scale: float | None = None)
```
[ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/bria_fibo/pipeline_bria_fibo.py#L201)
**パラメータ:**
prompt (`str` または `list[str]`、*省略可能*) : エンコードするプロンプト
device : (`torch.device`): torch デバイス
num_images_per_prompt (`int`) : プロンプトごとに生成すべき画像の数
guidance_scale (`float`) : classifier free guidance のガイダンススケール。
negative_prompt (`str` または `list[str]`、*省略可能*) : 画像生成をガイドしないプロンプト、またはプロンプトのリスト。`guidance_scale` が `1` 未満の場合、無視されます(ガイドを使用していない場合、無視されます)。

Xet Storage Details

Size:
11.1 kB
·
Xet hash:
2950d893456eb31597da25ba9499244c83d735ecb5f44f377a34b36dc219e22d

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.