File size: 1,031 Bytes
adb616c
 
 
 
 
 
c1380ce
adb616c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""Generate an image with the Q4_K Ideogram 4 DiT.

  python download_deps.py            # one time (gated base-repo access required)
  python usage.py "a poster that says HELLO"

Memory: the FP8 pipeline is large; on a 24 GB card you may need an offload/
sequential-load recipe (see recipe-q4_k.json).
"""
import sys
import torch
from ideogram4 import Ideogram4Pipeline, Ideogram4PipelineConfig
from gguf_loader import load_gguf_tensors, swap_branch

GGUF = "ideogram4-q4_k.gguf"
prompt = sys.argv[1] if len(sys.argv) > 1 else 'a storefront sign that says "FRESH COFFEE"'

pipe = Ideogram4Pipeline.from_pretrained(
    config=Ideogram4PipelineConfig(weights_repo="ideogram-ai/ideogram-4-fp8"),
    device="cuda", dtype=torch.bfloat16)

g = load_gguf_tensors(GGUF)
print("linears swapped:",
      swap_branch(pipe.conditional_transformer, g, "cond"),
      swap_branch(pipe.unconditional_transformer, g, "uncond"))

img = pipe(prompt, num_steps=48, height=1024, width=1024, seed=1000)[0]
img.save("out.png")
print("saved out.png")