Buckets:

download
raw
29.2 kB
import"../chunks/DsnmJJEf.js";import{i as S,h as z,C as Q,H as a,a as l,D as o,E as H,s as X}from"../chunks/BtE7mKSK.js";import{p as A,o as L,s as e,f as B,a as g,b as D,c as t,d as u,r as n,n as s}from"../chunks/jDjavuwI.js";import{E as O}from"../chunks/SrSJA0zO.js";const K='{"title":"Ideogram 4","local":"ideogram-4","sections":[{"title":"Text-to-image","local":"text-to-image","sections":[],"depth":2},{"title":"Prompt upsampling","local":"prompt-upsampling","sections":[{"title":"Remote (Ideogram API)","local":"remote-ideogram-api","sections":[],"depth":3},{"title":"Local (on-device)","local":"local-on-device","sections":[],"depth":3}],"depth":2},{"title":"Ideogram4Pipeline","local":"diffusers.Ideogram4Pipeline","sections":[],"depth":2},{"title":"Ideogram4PromptEnhancerHead","local":"diffusers.Ideogram4PromptEnhancerHead","sections":[],"depth":2},{"title":"Ideogram4PipelineOutput","local":"diffusers.pipelines.ideogram4.Ideogram4PipelineOutput","sections":[],"depth":2}],"depth":1}';var $=u('<meta name="hf:doc:metadata"/>'),ee=u("<p>Examples:</p> <!>",1),ae=u(`<p></p> <!> <!> <p>Ideogram 4 is a flow-matching text-to-image model that uses a multimodal text encoder and an asymmetric
classifier-free guidance scheme: a dedicated <code>unconditional_transformer</code> produces the negative branch with zeroed text
features, while the main <code>transformer</code> consumes the full packed text + image sequence.</p> <p>The pipeline defaults are the recommended settings for best quality, so a plain <code>pipe(prompt)</code> call produces
best-quality results out of the box: 48 flow-matching steps on a logit-normal schedule (<code>mu=0.0</code>, <code>std=1.5</code>) with
classifier-free guidance held at 7.0 for the main steps and dropped to 3.0 for the final 3 “polish” steps.</p> <p>Key inference-time knobs are exposed via the pipeline call:</p> <ul><li><code>num_inference_steps</code>, <code>mu</code>, and <code>std</code> control the resolution-aware logit-normal flow-matching schedule.</li> <li><code>guidance_scale</code> (or a full per-step <code>guidance_schedule</code>) blends the conditional and unconditional velocities.</li></ul> <!> <!> <!> <p>Ideogram 4 is trained on a structured JSON caption rather than a free-form prompt, so a short prompt is best
expanded into that native schema before generation. There are two ways to produce the caption.</p> <!> <p>For the best results, expand the prompt with Ideogram’s hosted magic-prompt API and pass the returned caption
straight to the pipeline (get a key at <a href="https://developer.ideogram.ai/" rel="nofollow">developer.ideogram.ai</a>):</p> <!> <!> <p>For a fully local pipeline, load a small <a href="/docs/diffusers/pr_14333/en/api/pipelines/ideogram4#diffusers.Ideogram4PromptEnhancerHead">Ideogram4PromptEnhancerHead</a> (the Qwen3-VL LM head) as the optional <code>prompt_enhancer_head</code> component and pass <code>prompt_upsampling=True</code>. The head is grafted onto the shared <code>text_encoder</code>, so no second text encoder is loaded. Install <code>outlines</code> for schema-constrained captions (the nf4
checkpoint also needs <code>bitsandbytes</code>):</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>Text-to-image pipeline for Ideogram4.</p> <p>Ideogram4 is a flow-matching model trained with asymmetric classifier-free guidance: a <code>transformer</code> consumes
text-conditioned features alongside the image latents, while a separate <code>unconditional_transformer</code> denoises with
zeroed text features. The two velocity predictions are linearly blended each step.</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>Run text-to-image generation.</p> <!></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"><!> <p>Prepare the conditioning for the packed text+image sequence (one entry per prompt).</p> <p>Returns a flat tuple <code>(prompt_embeds, position_ids, segment_ids, indicator)</code>. The unconditional branch carries
no text, so the pipeline builds its (zeroed) inputs directly rather than encoding a negative prompt.</p></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"><!> <p>Rewrite each prompt into Ideogram4’s native structured JSON caption.</p> <p>Requires the optional <code>prompt_enhancer_head</code> component, which is grafted onto the shared <code>text_encoder</code> body to
make it generative. Generation is schema-constrained when <code>outlines</code> is installed, otherwise it runs
unconstrained. Pass <code>generator</code> (the same one accepted by <code>__call__</code>) to make sampling reproducible.</p></div></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"><!> <p>LM head that makes the head-less Qwen3-VL <code>text_encoder</code> generative for prompt upsampling.</p> <p>An optional pipeline component (<code>prompt_enhancer_head</code>): its weights load via a normal <code>from_pretrained</code> (its own
small repo, or bundled in the model repo) rather than an in-pipeline download. At upsample time the pipeline
combines it with the shared <code>text_encoder</code> body to form the generative model.</p></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"><!> <p>Output class for the Ideogram 4 pipeline.</p></div> <!> <p></p>`,1);function re(E,q){A(q,!1),L(()=>{new URLSearchParams(window.location.search).get("fw")}),S();var f=ae();z("7hp0ki",r=>{var h=$();X(h,"content",K),g(r,h)});var _=e(B(f),2);Q(_,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var y=e(_,2);a(y,{title:"Ideogram 4",local:"ideogram-4",headingTag:"h1"});var M=e(y,10);a(M,{title:"Text-to-image",local:"text-to-image",headingTag:"h2"});var b=e(M,2);l(b,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwSWRlb2dyYW00UGlwZWxpbmUlMEElMEFwaXBlJTIwJTNEJTIwSWRlb2dyYW00UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmlkZW9ncmFtLWFpJTJGaWRlb2dyYW0tdjQlMjIlMkMlMjBkdHlwZSUzRHRvcmNoLmJmbG9hdDE2KSUwQXBpcGUudG8oJTIyY3VkYSUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJBJTIwcGhvdG8lMjBvZiUyMGElMjBjYXQlMjBob2xkaW5nJTIwYSUyMHNpZ24lMjB0aGF0JTIwc2F5cyUyMGhlbGxvJTIwd29ybGQlMjIlMEElMjMlMjBUaGUlMjBkZWZhdWx0cyUyMGFyZSUyMHRoZSUyMHJlY29tbWVuZGVkJTIwc2V0dGluZ3MlMjBmb3IlMjBiZXN0JTIwcXVhbGl0eS4lMEFpbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0JTJDJTIwaGVpZ2h0JTNEMTAyNCUyQyUyMHdpZHRoJTNEMTAyNCUyQyUyMGdlbmVyYXRvciUzRHRvcmNoLkdlbmVyYXRvciglMjJjdWRhJTIyKS5tYW51YWxfc2VlZCgwKSkuaW1hZ2VzJTVCMCU1RCUwQWltYWdlLnNhdmUoJTIyaWRlb2dyYW00LnBuZyUyMik=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> Ideogram4Pipeline
pipe = Ideogram4Pipeline.from_pretrained(<span class="hljs-string">&quot;ideogram-ai/ideogram-v4&quot;</span>, dtype=torch.bfloat16)
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
prompt = <span class="hljs-string">&quot;A photo of a cat holding a sign that says hello world&quot;</span>
<span class="hljs-comment"># The defaults are the recommended settings for best quality.</span>
image = pipe(prompt, height=<span class="hljs-number">1024</span>, width=<span class="hljs-number">1024</span>, generator=torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">0</span>)).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;ideogram4.png&quot;</span>)`,lang:"python",wrap:!1});var w=e(b,2);a(w,{title:"Prompt upsampling",local:"prompt-upsampling",headingTag:"h2"});var J=e(w,4);a(J,{title:"Remote (Ideogram API)",local:"remote-ideogram-api",headingTag:"h3"});var I=e(J,4);l(I,{code:"aW1wb3J0JTIwanNvbiUwQWltcG9ydCUyMHJlcXVlc3RzJTBBaW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwSWRlb2dyYW00UGlwZWxpbmUlMEElMEFwaXBlJTIwJTNEJTIwSWRlb2dyYW00UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmlkZW9ncmFtLWFpJTJGaWRlb2dyYW0tNC1uZjQlMjIlMkMlMjBkdHlwZSUzRHRvcmNoLmJmbG9hdDE2KSUwQXBpcGUudG8oJTIyY3VkYSUyMiklMEElMEElMjMlMjBFeHBhbmQlMjB0aGUlMjBwcm9tcHQlMjBpbnRvJTIwYSUyMHN0cnVjdHVyZWQlMjBKU09OJTIwY2FwdGlvbiUyMHdpdGglMjBJZGVvZ3JhbSdzJTIwaG9zdGVkJTIwbWFnaWMtcHJvbXB0JTIwQVBJLiUwQXJlc3BvbnNlJTIwJTNEJTIwcmVxdWVzdHMucG9zdCglMEElMjAlMjAlMjAlMjAlMjJodHRwcyUzQSUyRiUyRmFwaS5pZGVvZ3JhbS5haSUyRnYxJTJGaWRlb2dyYW0tdjQlMkZtYWdpYy1wcm9tcHQlMjIlMkMlMEElMjAlMjAlMjAlMjBoZWFkZXJzJTNEJTdCJTIyQXBpLUtleSUyMiUzQSUyMCUyMnlvdXJfaWRlb2dyYW1fYXBpX2tleSUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMGpzb24lM0QlN0IlMjJ0ZXh0X3Byb21wdCUyMiUzQSUyMCUyMkElMjBwaG90byUyMG9mJTIwYSUyMGNhdCUyMGhvbGRpbmclMjBhJTIwc2lnbiUyMHRoYXQlMjBzYXlzJTIwaGVsbG8lMjB3b3JsZCUyMiUyQyUyMCUyMmFzcGVjdF9yYXRpbyUyMiUzQSUyMCUyMjF4MSUyMiU3RCUyQyUwQSkuanNvbigpJTBBY2FwdGlvbiUyMCUzRCUyMGpzb24uZHVtcHMocmVzcG9uc2UlNUIlMjJqc29uX3Byb21wdCUyMiU1RCklMEElMEElMjMlMjBUaGUlMjBjYXB0aW9uJTIwaXMlMjBhbHJlYWR5JTIwdXBzYW1wbGVkJTJDJTIwc28lMjBwYXNzJTIwaXQlMjBkaXJlY3RseSUyMChubyUyMHByb21wdF91cHNhbXBsaW5nKS4lMEFpbWFnZSUyMCUzRCUyMHBpcGUoY2FwdGlvbiUyQyUyMGhlaWdodCUzRDEwMjQlMkMlMjB3aWR0aCUzRDEwMjQlMkMlMjBnZW5lcmF0b3IlM0R0b3JjaC5HZW5lcmF0b3IoJTIyY3VkYSUyMikubWFudWFsX3NlZWQoMCkpLmltYWdlcyU1QjAlNUQlMEFpbWFnZS5zYXZlKCUyMmlkZW9ncmFtNF91cHNhbXBsZWQucG5nJTIyKQ==",highlighted:`<span class="hljs-keyword">import</span> json
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> Ideogram4Pipeline
pipe = Ideogram4Pipeline.from_pretrained(<span class="hljs-string">&quot;ideogram-ai/ideogram-4-nf4&quot;</span>, dtype=torch.bfloat16)
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-comment"># Expand the prompt into a structured JSON caption with Ideogram&#x27;s hosted magic-prompt API.</span>
response = requests.post(
<span class="hljs-string">&quot;https://api.ideogram.ai/v1/ideogram-v4/magic-prompt&quot;</span>,
headers={<span class="hljs-string">&quot;Api-Key&quot;</span>: <span class="hljs-string">&quot;your_ideogram_api_key&quot;</span>},
json={<span class="hljs-string">&quot;text_prompt&quot;</span>: <span class="hljs-string">&quot;A photo of a cat holding a sign that says hello world&quot;</span>, <span class="hljs-string">&quot;aspect_ratio&quot;</span>: <span class="hljs-string">&quot;1x1&quot;</span>},
).json()
caption = json.dumps(response[<span class="hljs-string">&quot;json_prompt&quot;</span>])
<span class="hljs-comment"># The caption is already upsampled, so pass it directly (no prompt_upsampling).</span>
image = pipe(caption, height=<span class="hljs-number">1024</span>, width=<span class="hljs-number">1024</span>, generator=torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">0</span>)).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;ideogram4_upsampled.png&quot;</span>)`,lang:"python",wrap:!1});var v=e(I,2);a(v,{title:"Local (on-device)",local:"local-on-device",headingTag:"h3"});var T=e(v,4);l(T,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwSWRlb2dyYW00UGlwZWxpbmUlMkMlMjBJZGVvZ3JhbTRQcm9tcHRFbmhhbmNlckhlYWQlMEElMEFwcm9tcHRfZW5oYW5jZXJfaGVhZCUyMCUzRCUyMElkZW9ncmFtNFByb21wdEVuaGFuY2VySGVhZC5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyZGlmZnVzZXJzJTJGcXdlbjMtdmwtOGItaW5zdHJ1Y3QtbG0taGVhZCUyMiUyQyUyMGR0eXBlJTNEdG9yY2guYmZsb2F0MTYlMEEpJTBBcGlwZSUyMCUzRCUyMElkZW9ncmFtNFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJpZGVvZ3JhbS1haSUyRmlkZW9ncmFtLTQtbmY0JTIyJTJDJTIwcHJvbXB0X2VuaGFuY2VyX2hlYWQlM0Rwcm9tcHRfZW5oYW5jZXJfaGVhZCUyQyUyMGR0eXBlJTNEdG9yY2guYmZsb2F0MTYlMEEpJTBBcGlwZS50byglMjJjdWRhJTIyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkElMjBwaG90byUyMG9mJTIwYSUyMGNhdCUyMGhvbGRpbmclMjBhJTIwc2lnbiUyMHRoYXQlMjBzYXlzJTIwaGVsbG8lMjB3b3JsZCUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZSglMEElMjAlMjAlMjAlMjBwcm9tcHQlMkMlMEElMjAlMjAlMjAlMjBoZWlnaHQlM0QxMDI0JTJDJTBBJTIwJTIwJTIwJTIwd2lkdGglM0QxMDI0JTJDJTBBJTIwJTIwJTIwJTIwcHJvbXB0X3Vwc2FtcGxpbmclM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwZ2VuZXJhdG9yJTNEdG9yY2guR2VuZXJhdG9yKCUyMmN1ZGElMjIpLm1hbnVhbF9zZWVkKDApJTJDJTBBKS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2Uuc2F2ZSglMjJpZGVvZ3JhbTRfdXBzYW1wbGVkLnBuZyUyMik=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> Ideogram4Pipeline, Ideogram4PromptEnhancerHead
prompt_enhancer_head = Ideogram4PromptEnhancerHead.from_pretrained(
<span class="hljs-string">&quot;diffusers/qwen3-vl-8b-instruct-lm-head&quot;</span>, dtype=torch.bfloat16
)
pipe = Ideogram4Pipeline.from_pretrained(
<span class="hljs-string">&quot;ideogram-ai/ideogram-4-nf4&quot;</span>, prompt_enhancer_head=prompt_enhancer_head, dtype=torch.bfloat16
)
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
prompt = <span class="hljs-string">&quot;A photo of a cat holding a sign that says hello world&quot;</span>
image = pipe(
prompt,
height=<span class="hljs-number">1024</span>,
width=<span class="hljs-number">1024</span>,
prompt_upsampling=<span class="hljs-literal">True</span>,
generator=torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">0</span>),
).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;ideogram4_upsampled.png&quot;</span>)`,lang:"python",wrap:!1});var j=e(T,2);a(j,{title:"Ideogram4Pipeline",local:"diffusers.Ideogram4Pipeline",headingTag:"h2"});var i=e(j,2),U=t(i);o(U,{name:"class diffusers.Ideogram4Pipeline",anchor:"diffusers.Ideogram4Pipeline",source:"https://github.com/huggingface/diffusers/blob/vr_14333/src/diffusers/pipelines/ideogram4/pipeline_ideogram4.py#L141",parameters:[{name:"scheduler",val:": FlowMatchEulerDiscreteScheduler"},{name:"vae",val:": AutoencoderKLFlux2"},{name:"text_encoder",val:": PreTrainedModel"},{name:"tokenizer",val:": AutoTokenizer"},{name:"transformer",val:": Ideogram4Transformer2DModel"},{name:"unconditional_transformer",val:": Ideogram4Transformer2DModel"},{name:"prompt_enhancer_head",val:": diffusers.pipelines.ideogram4.prompt_enhancer.Ideogram4PromptEnhancerHead | None = None"}],parametersDescription:[{anchor:"diffusers.Ideogram4Pipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/pr_14333/en/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler">FlowMatchEulerDiscreteScheduler</a>) &#x2014;
Flow-matching scheduler. The pipeline overrides the default sigma schedule with a resolution-aware
logit-normal schedule.`,name:"scheduler"},{anchor:"diffusers.Ideogram4Pipeline.vae",description:`<strong>vae</strong> (<code>AutoencoderKLFlux2</code>) &#x2014;
Variational auto-encoder used to decode latents back into images.`,name:"vae"},{anchor:"diffusers.Ideogram4Pipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>PreTrainedModel</code>) &#x2014;
Multimodal text encoder. The pipeline consumes hidden states from a fixed set of intermediate decoder
layers (see <code>QWEN3_VL_ACTIVATION_LAYERS</code>).`,name:"text_encoder"},{anchor:"diffusers.Ideogram4Pipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>AutoTokenizer</code>) &#x2014;
Tokenizer paired with <code>text_encoder</code>.`,name:"tokenizer"},{anchor:"diffusers.Ideogram4Pipeline.transformer",description:`<strong>transformer</strong> (<a href="/docs/diffusers/pr_14333/en/api/models/ideogram4_transformer2d#diffusers.Ideogram4Transformer2DModel">Ideogram4Transformer2DModel</a>) &#x2014;
Conditional flow-matching transformer.`,name:"transformer"},{anchor:"diffusers.Ideogram4Pipeline.unconditional_transformer",description:`<strong>unconditional_transformer</strong> (<a href="/docs/diffusers/pr_14333/en/api/models/ideogram4_transformer2d#diffusers.Ideogram4Transformer2DModel">Ideogram4Transformer2DModel</a>) &#x2014;
Unconditional (asymmetric-CFG) flow-matching transformer.`,name:"unconditional_transformer"}]});var d=e(U,6),G=t(d);o(G,{name:"__call__",anchor:"diffusers.Ideogram4Pipeline.__call__",source:"https://github.com/huggingface/diffusers/blob/vr_14333/src/diffusers/pipelines/ideogram4/pipeline_ideogram4.py#L481",parameters:[{name:"prompt",val:": str | list[str] | None = None"},{name:"height",val:": int = 2048"},{name:"width",val:": int = 2048"},{name:"num_inference_steps",val:": int = 48"},{name:"guidance_scale",val:": float | None = None"},{name:"guidance_schedule",val:": typing.Union[list[float], torch.Tensor, NoneType] = (7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 7.0, 3.0, 3.0, 3.0)"},{name:"mu",val:": float = 0.0"},{name:"std",val:": float = 1.5"},{name:"prompt_upsampling",val:": bool = False"},{name:"prompt_upsampling_temperature",val:": float = 1.0"},{name:"max_sequence_length",val:": int = 2048"},{name:"num_images_per_prompt",val:": int = 1"},{name:"generator",val:": typing.Union[torch.Generator, list[torch.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.Tensor] = None"},{name:"output_type",val:": str = '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[[ForwardRef('Ideogram4Pipeline'), int, int, dict[str, typing.Any]], dict[str, typing.Any]]] = None"},{name:"callback_on_step_end_tensor_inputs",val:": list = ['latents']"}],parametersDescription:[{anchor:"diffusers.Ideogram4Pipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>list[str]</code>) &#x2014;
Prompt(s) to guide image generation.`,name:"prompt"},{anchor:"diffusers.Ideogram4Pipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
Output image height in pixels; must be a multiple of <code>vae_scale_factor * patch_size</code>.`,name:"height"},{anchor:"diffusers.Ideogram4Pipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
Output image width in pixels; must be a multiple of <code>vae_scale_factor * patch_size</code>.`,name:"width"},{anchor:"diffusers.Ideogram4Pipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 48) &#x2014;
Number of flow-matching steps. The default is the recommended setting for best quality.`,name:"num_inference_steps"},{anchor:"diffusers.Ideogram4Pipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>) &#x2014;
Constant classifier-free guidance scale applied at every step. The conditional and unconditional
velocity predictions are blended as <code>v = guidance_scale * v_pos + (1 - guidance_scale) * v_neg</code>.
Mutually exclusive with <code>guidance_schedule</code> (setting both raises). Defaults to <code>None</code>.`,name:"guidance_scale"},{anchor:"diffusers.Ideogram4Pipeline.__call__.guidance_schedule",description:`<strong>guidance_schedule</strong> (<code>list[float]</code> or <code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Per-step guidance scale schedule; must have length <code>num_inference_steps</code>. The first entry corresponds
to the first step (largest noise level). Mutually exclusive with <code>guidance_scale</code>; exactly one must be
set. Defaults to the recommended schedule (7.0 for the main steps, dropping to 3.0 for the final 3
&#x201C;polish&#x201D; steps). To use a constant scale instead, pass <code>guidance_scale</code> and <code>guidance_schedule=None</code>.`,name:"guidance_schedule"},{anchor:"diffusers.Ideogram4Pipeline.__call__.mu",description:`<strong>mu</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Base mean of the logit-normal flow-matching schedule. The schedule mean is shifted by half the log of
the resolution ratio relative to 512x512.`,name:"mu"},{anchor:"diffusers.Ideogram4Pipeline.__call__.std",description:`<strong>std</strong> (<code>float</code>, <em>optional</em>, defaults to 1.5) &#x2014;
Standard deviation of the logit-normal flow-matching schedule.`,name:"std"},{anchor:"diffusers.Ideogram4Pipeline.__call__.prompt_upsampling",description:`<strong>prompt_upsampling</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
If <code>True</code>, rewrite <code>prompt</code> into Ideogram4&#x2019;s native structured JSON caption via
<a href="/docs/diffusers/pr_14333/en/api/pipelines/ideogram4#diffusers.Ideogram4Pipeline.upsample_prompt">upsample_prompt()</a> before encoding. Requires the optional <code>prompt_enhancer_head</code>
component; install <code>outlines</code> for schema-constrained captions. <code>generator</code> is reused to make the
upsampling reproducible.`,name:"prompt_upsampling"},{anchor:"diffusers.Ideogram4Pipeline.__call__.prompt_upsampling_temperature",description:`<strong>prompt_upsampling_temperature</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
Sampling temperature for prompt upsampling when <code>prompt_upsampling=True</code>.`,name:"prompt_upsampling_temperature"},{anchor:"diffusers.Ideogram4Pipeline.__call__.max_sequence_length",description:`<strong>max_sequence_length</strong> (<code>int</code>, <em>optional</em>, defaults to 2048) &#x2014;
Maximum number of text tokens per prompt.`,name:"max_sequence_length"},{anchor:"diffusers.Ideogram4Pipeline.__call__.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Number of images to generate per prompt.`,name:"num_images_per_prompt"},{anchor:"diffusers.Ideogram4Pipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>list[torch.Generator]</code>, <em>optional</em>) &#x2014;
Generator(s) used to make sampling deterministic.`,name:"generator"},{anchor:"diffusers.Ideogram4Pipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-generated noise of shape <code>(batch_size, num_image_tokens, latent_dim)</code>.`,name:"latents"},{anchor:"diffusers.Ideogram4Pipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
One of <code>&quot;pil&quot;</code>, <code>&quot;np&quot;</code>, <code>&quot;pt&quot;</code>, or <code>&quot;latent&quot;</code>.`,name:"output_type"},{anchor:"diffusers.Ideogram4Pipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to return an <a href="/docs/diffusers/pr_14333/en/api/pipelines/ideogram4#diffusers.pipelines.ideogram4.Ideogram4PipelineOutput">Ideogram4PipelineOutput</a>.`,name:"return_dict"},{anchor:"diffusers.Ideogram4Pipeline.__call__.attention_kwargs",description:`<strong>attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
A kwargs dictionary passed along to the attention processor of each transformer. A <code>&quot;scale&quot;</code> entry
scales the loaded LoRA weights (e.g. <code>{&quot;scale&quot;: 0.7}</code>) when the PEFT backend is active.`,name:"attention_kwargs"},{anchor:"diffusers.Ideogram4Pipeline.__call__.callback_on_step_end",description:`<strong>callback_on_step_end</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
Callback invoked at the end of every denoising step.`,name:"callback_on_step_end"},{anchor:"diffusers.Ideogram4Pipeline.__call__.callback_on_step_end_tensor_inputs",description:`<strong>callback_on_step_end_tensor_inputs</strong> (<code>list[str]</code>, <em>optional</em>) &#x2014;
Names of tensors to expose to the callback via <code>callback_kwargs</code>.`,name:"callback_on_step_end_tensor_inputs"}],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p><a
href="/docs/diffusers/pr_14333/en/api/pipelines/ideogram4#diffusers.pipelines.ideogram4.Ideogram4PipelineOutput"
>Ideogram4PipelineOutput</a> or <code>tuple</code>.</p>
`});var P=e(G,4);O(P,{anchor:"diffusers.Ideogram4Pipeline.__call__.example",children:(r,h)=>{var k=ee(),N=e(B(k),2);l(N,{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwSWRlb2dyYW00UGlwZWxpbmUlMEElMEFwaXBlJTIwJTNEJTIwSWRlb2dyYW00UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmlkZW9ncmFtLWFpJTJGaWRlb2dyYW0tdjQlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmJmbG9hdDE2KSUwQXBpcGUudG8oJTIyY3VkYSUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJBJTIwcGhvdG8lMjBvZiUyMGElMjBjYXQlMjBob2xkaW5nJTIwYSUyMHNpZ24lMjB0aGF0JTIwc2F5cyUyMGhlbGxvJTIwd29ybGQlMjIlMEElMjMlMjBUaGUlMjBkZWZhdWx0cyUyMGFyZSUyMHRoZSUyMHJlY29tbWVuZGVkJTIwc2V0dGluZ3MlMjBmb3IlMjBiZXN0JTIwcXVhbGl0eS4lMEFpbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0JTJDJTIwaGVpZ2h0JTNEMjA0OCUyQyUyMHdpZHRoJTNEMjA0OCUyQyUyMGdlbmVyYXRvciUzRHRvcmNoLkdlbmVyYXRvciglMjJjdWRhJTIyKS5tYW51YWxfc2VlZCgwKSkuaW1hZ2VzJTVCMCU1RCUwQWltYWdlLnNhdmUoJTIyaWRlb2dyYW00LnBuZyUyMik=",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> Ideogram4Pipeline
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = Ideogram4Pipeline.from_pretrained(<span class="hljs-string">&quot;ideogram-ai/ideogram-v4&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-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;A photo of a cat holding a sign that says hello world&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># The defaults are the recommended settings for best quality.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(prompt, height=<span class="hljs-number">2048</span>, width=<span class="hljs-number">2048</span>, generator=torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(<span class="hljs-number">0</span>)).images[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">&quot;ideogram4.png&quot;</span>)`,lang:"py",wrap:!1}),g(r,k)},$$slots:{default:!0}}),n(d);var p=e(d,2),R=t(p);o(R,{name:"encode_prompt",anchor:"diffusers.Ideogram4Pipeline.encode_prompt",source:"https://github.com/huggingface/diffusers/blob/vr_14333/src/diffusers/pipelines/ideogram4/pipeline_ideogram4.py#L335",parameters:[{name:"prompt",val:": str | list[str]"},{name:"grid_h",val:": int"},{name:"grid_w",val:": int"},{name:"max_sequence_length",val:": int"},{name:"device",val:": device"}]}),s(4),n(p);var W=e(p,2),Y=t(W);o(Y,{name:"upsample_prompt",anchor:"diffusers.Ideogram4Pipeline.upsample_prompt",source:"https://github.com/huggingface/diffusers/blob/vr_14333/src/diffusers/pipelines/ideogram4/pipeline_ideogram4.py#L204",parameters:[{name:"prompt",val:": str | list[str]"},{name:"height",val:": int = 2048"},{name:"width",val:": int = 2048"},{name:"temperature",val:": float = 1.0"},{name:"max_new_tokens",val:": int = 1024"},{name:"generator",val:": typing.Union[torch.Generator, list[torch.Generator], NoneType] = None"},{name:"device",val:": typing.Optional[torch.device] = None"}]}),s(4),n(W),n(i);var Z=e(i,2);a(Z,{title:"Ideogram4PromptEnhancerHead",local:"diffusers.Ideogram4PromptEnhancerHead",headingTag:"h2"});var c=e(Z,2),F=t(c);o(F,{name:"class diffusers.Ideogram4PromptEnhancerHead",anchor:"diffusers.Ideogram4PromptEnhancerHead",source:"https://github.com/huggingface/diffusers/blob/vr_14333/src/diffusers/pipelines/ideogram4/prompt_enhancer.py#L42",parameters:[{name:"hidden_size",val:": int = 4096"},{name:"vocab_size",val:": int = 151936"}]}),s(4),n(c);var x=e(c,2);a(x,{title:"Ideogram4PipelineOutput",local:"diffusers.pipelines.ideogram4.Ideogram4PipelineOutput",headingTag:"h2"});var m=e(x,2),V=t(m);o(V,{name:"class diffusers.pipelines.ideogram4.Ideogram4PipelineOutput",anchor:"diffusers.pipelines.ideogram4.Ideogram4PipelineOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14333/src/diffusers/pipelines/ideogram4/pipeline_output.py#L24",parameters:[{name:"images",val:": list[PIL.Image.Image] | numpy.ndarray"}],parametersDescription:[{anchor:"diffusers.pipelines.ideogram4.Ideogram4PipelineOutput.images",description:`<strong>images</strong> (<code>list[PIL.Image.Image]</code> or <code>np.ndarray</code>) &#x2014;
List of denoised PIL images of length <code>batch_size</code>, or numpy array of shape <code>(batch_size, height, width, num_channels)</code>.`,name:"images"}]}),s(2),n(m);var C=e(m,2);H(C,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/ideogram4.md"}),s(2),g(E,f),D()}export{re as component};

Xet Storage Details

Size:
29.2 kB
·
Xet hash:
681da63f6130087a4060a6e4787dd850c172b2dedca24a4a64adc4a4c6bc5e12

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