Buckets:

download
raw
21 kB
import"../chunks/DsnmJJEf.js";import{i as J,h as U,C as P,H as t,a as B,D as s,E as N,s as F}from"../chunks/BtE7mKSK.js";import{p as Z,o as C,s as e,f as T,a as r,b as q,c as l,d as c,r as d,n as E}from"../chunks/jDjavuwI.js";import{E as R}from"../chunks/SrSJA0zO.js";const Y='{"title":"Bria 3.2","local":"bria-32","sections":[{"title":"Usage","local":"usage","sections":[],"depth":2},{"title":"BriaPipeline","local":"diffusers.BriaPipeline","sections":[],"depth":2}],"depth":1}';var z=c('<meta name="hf:doc:metadata"/>'),A=c("<p>Examples:</p> <!>",1),W=c(`<p></p> <!> <!> <p>Bria 3.2 is the next-generation commercial-ready text-to-image model. With just 4 billion parameters, it provides exceptional aesthetics and text rendering, evaluated to provide on par results to leading open-source models, and outperforming other licensed models.
In addition to being built entirely on licensed data, 3.2 provides several advantages for enterprise and commercial use:</p> <ul><li>Efficient Compute - the model is X3 smaller than the equivalent models in the market (4B parameters vs 12B parameters other open source models)</li> <li>Architecture Consistency: Same architecture as 3.1—ideal for users looking to upgrade without disruption.</li> <li>Fine-tuning Speedup: 2x faster fine-tuning on L40S and A100.</li></ul> <p>Original model checkpoints for Bria 3.2 can be found <a href="https://huggingface.co/briaai/BRIA-3.2" rel="nofollow">here</a>.
Github repo for Bria 3.2 can be found <a href="https://github.com/Bria-AI/BRIA-3.2" rel="nofollow">here</a>.</p> <p>If you want to learn more about the Bria platform, and get free traril access, please visit <a href="https://bria.ai" rel="nofollow">bria.ai</a>.</p> <!> <p><em>As the model is gated, before using it with diffusers you first need to go to the <a href="https://huggingface.co/briaai/BRIA-3.2" rel="nofollow">Bria 3.2 Hugging Face page</a>, fill in the form and accept the gate. Once you are in, you need to login so that your system knows you’ve accepted the gate.</em></p> <p>Use the command below to log in:</p> <!> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Based on FluxPipeline with several changes:</p> <ul><li>no pooled embeddings</li> <li>We use zero padding for prompts</li> <li>No guidance embedding since this is not a distilled version</li></ul> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Function invoked when calling the pipeline for generation.</p> <p>&#60;&#60;&#60;&#60;&#60;&#60;&#60; HEAD
Guidance scale as defined in <a href="https://arxiv.org/abs/2207.12598" rel="nofollow">Classifier-Free Diffusion
Guidance</a>. <code>guidance_scale</code> is defined as <code>w</code> of equation 2.
of <a href="https://arxiv.org/pdf/2205.11487.pdf" rel="nofollow">Imagen Paper</a>. Guidance scale is enabled by setting <code>guidance_scale &gt; 1</code>. Higher guidance scale encourages to generate images that are closely
linked to the text <code>prompt</code>, usually at the expense of lower image quality.</p> <!> <p>Guidance scale as defined in <a href="https://huggingface.co/papers/2207.12598" rel="nofollow">Classifier-Free Diffusion
Guidance</a>. <code>guidance_scale</code> is defined as <code>w</code> of
equation 2. of <a href="https://huggingface.co/papers/2205.11487" rel="nofollow">Imagen Paper</a>. Guidance scale is
enabled by setting <code>guidance_scale &gt; 1</code>. Higher guidance scale encourages to generate images
that are closely linked to the text <code>prompt</code>, usually at the expense of lower image quality.
negative_prompt (<code>str</code> or <code>list[str]</code>, <em>optional</em>):</p> <blockquote><blockquote><blockquote><blockquote><blockquote><blockquote><blockquote><p>main
The prompt or prompts not to guide the image generation. If not defined, one has to pass <code>negative_prompt_embeds</code> instead. Ignored when not using guidance (i.e., ignored if <code>guidance_scale</code> is less than <code>1</code>).
num_images_per_prompt (<code>int</code>, <em>optional</em>, defaults to 1):
The number of images to generate per prompt.
generator (<code>torch.Generator</code> or <code>list[torch.Generator]</code>, <em>optional</em>):
One or a list of <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch
generator(s)</a> to make
generation deterministic.
latents (<code>torch.FloatTensor</code>, <em>optional</em>):
Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for
image generation. Can be used to tweak the same generation with different prompts. If not
provided, a latents tensor will be generated by sampling using the supplied random <code>generator</code>.
prompt_embeds (<code>torch.FloatTensor</code>, <em>optional</em>):
Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt
weighting. If not provided, text embeddings will be generated from <code>prompt</code> input argument.
negative_prompt_embeds (<code>torch.FloatTensor</code>, <em>optional</em>):
Pre-generated negative text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt
weighting. If not provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input argument.
output_type (<code>str</code>, <em>optional</em>, defaults to <code>"pil"</code>):
The output format of the generate image. Choose between <a href="https://pillow.readthedocs.io/en/stable/" rel="nofollow">PIL</a>: <code>PIL.Image.Image</code> or <code>np.array</code>.
return_dict (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>):
Whether or not to return a <code>~pipelines.bria.BriaPipelineOutput</code> instead of a plain tuple.
attention_kwargs (<code>dict</code>, <em>optional</em>):
A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined
under <code>self.processor</code> in <a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow">diffusers.models.attention_processor</a>.
callback_on_step_end (<code>Callable</code>, <em>optional</em>):
A function that calls at the end of each denoising steps during the inference. The function is
called with the following arguments: <code>callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)</code>. <code>callback_kwargs</code> will include a list of all tensors as
specified by <code>callback_on_step_end_tensor_inputs</code>.
callback_on_step_end_tensor_inputs (<code>list</code>, <em>optional</em>):
The list of tensor inputs for the <code>callback_on_step_end</code> function. The tensors specified in the
list will be passed as <code>callback_kwargs</code> argument. You will only be able to include variables
listed in the <code>._callback_tensor_inputs</code> attribute of your pipeline class.
max_sequence_length (<code>int</code> defaults to 256): Maximum sequence length to use with the <code>prompt</code>.
clip_value (<code>float</code>, <em>optional</em>):
If set, the predicted noise is clipped to the range <code>[-clip_value, clip_value]</code> at each
denoising step.
normalize (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>):
Whether to normalize the predicted noise at each denoising step.</p></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote> <!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!></div></div> <!> <p></p>`,1);function H(M,x){Z(x,!1),C(()=>{new URLSearchParams(window.location.search).get("fw")}),J();var p=W();U("1dqn4q9",o=>{var i=z();F(i,"content",Y),r(o,i)});var m=e(T(p),2);P(m,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var g=e(m,2);t(g,{title:"Bria 3.2",local:"bria-32",headingTag:"h1"});var u=e(g,10);t(u,{title:"Usage",local:"usage",headingTag:"h2"});var h=e(u,6);B(h,{code:"aGYlMjBhdXRoJTIwbG9naW4=",highlighted:"hf auth login",lang:"bash",wrap:!1});var f=e(h,2);t(f,{title:"BriaPipeline",local:"diffusers.BriaPipeline",headingTag:"h2"});var n=e(f,2),_=l(n);s(_,{name:"class diffusers.BriaPipeline",anchor:"diffusers.BriaPipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14169/src/diffusers/pipelines/bria/pipeline_bria.py#L89",parameters:[{name:"transformer",val:": BriaTransformer2DModel"},{name:"scheduler",val:": diffusers.schedulers.scheduling_flow_match_euler_discrete.FlowMatchEulerDiscreteScheduler | diffusers.schedulers.scheduling_utils.KarrasDiffusionSchedulers"},{name:"vae",val:": AutoencoderKL"},{name:"text_encoder",val:": T5EncoderModel"},{name:"tokenizer",val:": T5Tokenizer"},{name:"image_encoder",val:": CLIPVisionModelWithProjection = None"},{name:"feature_extractor",val:": CLIPImageProcessorPil = None"}],parametersDescription:[{anchor:"diffusers.BriaPipeline.transformer",description:`<strong>transformer</strong> (<a href="/docs/diffusers/pr_14169/en/api/models/bria_transformer#diffusers.BriaTransformer2DModel">BriaTransformer2DModel</a>) &#x2014;
Conditional Transformer (MMDiT) architecture to denoise the encoded image latents.`,name:"transformer"},{anchor:"diffusers.BriaPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/pr_14169/en/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler">FlowMatchEulerDiscreteScheduler</a>) &#x2014;
A scheduler to be used in combination with <code>transformer</code> to denoise the encoded image latents.`,name:"scheduler"},{anchor:"diffusers.BriaPipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/pr_14169/en/api/models/autoencoderkl#diffusers.AutoencoderKL">AutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.BriaPipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>T5EncoderModel</code>) &#x2014;
Frozen text-encoder. Bria uses
<a href="https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5EncoderModel" rel="nofollow">T5</a>, specifically the
<a href="https://huggingface.co/google/t5-v1_1-xxl" rel="nofollow">t5-v1_1-xxl</a> variant.`,name:"text_encoder"},{anchor:"diffusers.BriaPipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>T5TokenizerFast</code>) &#x2014;
Tokenizer of class
<a href="https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5Tokenizer" rel="nofollow">T5Tokenizer</a>.`,name:"tokenizer"}]});var a=e(_,6),b=l(a);s(b,{name:"__call__",anchor:"diffusers.BriaPipeline.__call__",source:"https://github.com/huggingface/diffusers/blob/vr_14169/src/diffusers/pipelines/bria/pipeline_bria.py#L448",parameters:[{name:"prompt",val:": str | list[str] = None"},{name:"height",val:": int | None = None"},{name:"width",val:": int | None = None"},{name:"num_inference_steps",val:": int = 30"},{name:"timesteps",val:": list = None"},{name:"guidance_scale",val:": float = 5"},{name:"negative_prompt",val:": str | list[str] | None = None"},{name:"num_images_per_prompt",val:": int | None = 1"},{name:"generator",val:": typing.Union[torch.Generator, list[torch.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.FloatTensor] = None"},{name:"prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_type",val:": str | None = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"attention_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"callback_on_step_end",val:": typing.Optional[typing.Callable[[int, int], NoneType]] = None"},{name:"callback_on_step_end_tensor_inputs",val:": list = ['latents']"},{name:"max_sequence_length",val:": int = 128"},{name:"clip_value",val:": None | float = None"},{name:"normalize",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.BriaPipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide the image generation. If not defined, one has to pass
<code>prompt_embeds</code>. instead.`,name:"prompt"},{anchor:"diffusers.BriaPipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to self.unet.config.sample_size * self.vae_scale_factor) &#x2014;
The height in pixels of the generated image. This is set to 1024 by default for the best
results.`,name:"height"},{anchor:"diffusers.BriaPipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to self.unet.config.sample_size * self.vae_scale_factor) &#x2014;
The width in pixels of the generated image. This is set to 1024 by default for the best
results.`,name:"width"},{anchor:"diffusers.BriaPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 50) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at
the expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.BriaPipeline.__call__.timesteps",description:`<strong>timesteps</strong> (<code>list[int]</code>, <em>optional</em>) &#x2014;
Custom timesteps to use for the denoising process with schedulers which support a <code>timesteps</code>
argument in their <code>set_timesteps</code> method. If not defined, the default behavior when
<code>num_inference_steps</code> is passed will be used. Must be in descending order.`,name:"timesteps"},{anchor:"diffusers.BriaPipeline.__call__.guidance_scale",description:"<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 5.0) &#x2014;",name:"guidance_scale"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>~pipelines.bria.BriaPipelineOutput</code> if
<code>return_dict</code> is True, otherwise a <code>tuple</code>. When returning a tuple, the first element is a list
with the generated images.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>~pipelines.bria.BriaPipelineOutput</code> or <code>tuple</code></p>
`});var v=e(b,6);t(v,{title:"negative_prompt ( str or list[str] , optional ):",local:"negativeprompt--str-or-liststr--optional-",headingTag:"h1"});var k=e(v,6);R(k,{anchor:"diffusers.BriaPipeline.__call__.example",children:(o,i)=>{var y=A(),G=e(T(y),2);B(G,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQnJpYVBpcGVsaW5lJTBBJTBBcGlwZSUyMCUzRCUyMEJyaWFQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIyYnJpYWFpJTJGQlJJQS0zLjIlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2KSUwQXBpcGUudG8oJTIyY3VkYSUyMiklMEElMEFwaXBlLnRleHRfZW5jb2RlciUyMCUzRCUyMHBpcGUudGV4dF9lbmNvZGVyLnRvKGR0eXBlJTNEdG9yY2guYmZsb2F0MTYpJTBBZm9yJTIwYmxvY2slMjBpbiUyMHBpcGUudGV4dF9lbmNvZGVyLmVuY29kZXIuYmxvY2slM0ElMEElMjAlMjAlMjAlMjBibG9jay5sYXllciU1Qi0xJTVELkRlbnNlUmVsdURlbnNlLndvLnRvKGR0eXBlJTNEdG9yY2guZmxvYXQzMiklMEElMEFpZiUyMHBpcGUudmFlLmNvbmZpZy5zaGlmdF9mYWN0b3IlMjAlM0QlM0QlMjAwJTNBJTBBJTIwJTIwJTIwJTIwcGlwZS52YWUudG8oZHR5cGUlM0R0b3JjaC5mbG9hdDMyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMlBob3RvcmVhbGlzdGljJTIwZm9vZCUyMHBob3RvZ3JhcGh5JTIwb2YlMjBhJTIwc3RhY2slMjBvZiUyMGZsdWZmeSUyMHBhbmNha2VzJTIwb24lMjBhJTIwd2hpdGUlMjBwbGF0ZSUyQyUyMHdpdGglMjBtYXBsZSUyMHN5cnVwJTIwYmVpbmclMjBwb3VyZWQlMjBvdmVyJTIwdGhlbS4lMjBPbiUyMHRvcCUyMG9mJTIwdGhlJTIwcGFuY2FrZXMlMjBhcmUlMjB0aGUlMjB3b3JkcyUyMCdCUklBJTIwMy4yJyUyMGluJTIwYm9sZCUyQyUyMHllbGxvdyUyQyUyMDNEJTIwbGV0dGVycy4lMjBUaGUlMjBiYWNrZ3JvdW5kJTIwaXMlMjBkYXJrJTIwYW5kJTIwb3V0JTIwb2YlMjBmb2N1cy4lMjIlMEFpbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0KS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2Uuc2F2ZSglMjJicmlhLnBuZyUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> BriaPipeline
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = BriaPipeline.from_pretrained(<span class="hljs-string">&quot;briaai/BRIA-3.2&quot;</span>, torch_dtype=torch.bfloat16)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-comment"># BRIA&#x27;s T5 text encoder is sensitive to precision. We need to cast it to bfloat16 and keep the final layer in float32.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.text_encoder = pipe.text_encoder.to(dtype=torch.bfloat16)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> block <span class="hljs-keyword">in</span> pipe.text_encoder.encoder.block:
<span class="hljs-meta">... </span> block.layer[-<span class="hljs-number">1</span>].DenseReluDense.wo.to(dtype=torch.float32)
<span class="hljs-comment"># BRIA&#x27;s VAE is not supported in mixed precision, so we use float32.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">if</span> pipe.vae.config.shift_factor == <span class="hljs-number">0</span>:
<span class="hljs-meta">... </span> pipe.vae.to(dtype=torch.float32)
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;Photorealistic food photography of a stack of fluffy pancakes on a white plate, with maple syrup being poured over them. On top of the pancakes are the words &#x27;BRIA 3.2&#x27; in bold, yellow, 3D letters. The background is dark and out of focus.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(prompt).images[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">&quot;bria.png&quot;</span>)`,lang:"py",wrap:!1}),r(o,y)},$$slots:{default:!0}}),d(a);var w=e(a,2),I=l(w);s(I,{name:"encode_prompt",anchor:"diffusers.BriaPipeline.encode_prompt",source:"https://github.com/huggingface/diffusers/blob/vr_14169/src/diffusers/pipelines/bria/pipeline_bria.py#L146",parameters:[{name:"prompt",val:": str | list[str]"},{name:"device",val:": typing.Optional[torch.device] = None"},{name:"num_images_per_prompt",val:": int = 1"},{name:"do_classifier_free_guidance",val:": bool = True"},{name:"negative_prompt",val:": str | list[str] | None = None"},{name:"prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"max_sequence_length",val:": int = 128"},{name:"lora_scale",val:": float | None = None"}],parametersDescription:[{anchor:"diffusers.BriaPipeline.encode_prompt.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
prompt to be encoded`,name:"prompt"},{anchor:"diffusers.BriaPipeline.encode_prompt.device",description:`<strong>device</strong> &#x2014; (<code>torch.device</code>):
torch device`,name:"device"},{anchor:"diffusers.BriaPipeline.encode_prompt.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>) &#x2014;
number of images that should be generated per prompt`,name:"num_images_per_prompt"},{anchor:"diffusers.BriaPipeline.encode_prompt.do_classifier_free_guidance",description:`<strong>do_classifier_free_guidance</strong> (<code>bool</code>) &#x2014;
whether to use classifier free guidance or not`,name:"do_classifier_free_guidance"},{anchor:"diffusers.BriaPipeline.encode_prompt.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>list[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts not to guide the image generation. If not defined, one has to pass
<code>negative_prompt_embeds</code> instead. Ignored when not using guidance (i.e., ignored if <code>guidance_scale</code> is
less than <code>1</code>).`,name:"negative_prompt"},{anchor:"diffusers.BriaPipeline.encode_prompt.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not
provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.BriaPipeline.encode_prompt.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt
weighting. If not provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input
argument.`,name:"negative_prompt_embeds"}]}),d(w),d(n);var j=e(n,2);N(j,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/bria_3_2.md"}),E(2),r(M,p),q()}export{H as component};

Xet Storage Details

Size:
21 kB
·
Xet hash:
0827062622fdbfecaa37cc79da6ab2fb9dd020341f2e38d106ad117ab52bf727

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