mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-11-26 23:29:53 +00:00
44 lines
1.7 KiB
Text
44 lines
1.7 KiB
Text
# version: 0.0.0
|
|
# docs/models/fibo2.md — Fibo 2.0 Dev
|
|
|
|
var {
|
|
model_path = "../models/diffusion_models/fibo2_dev_int8_convrot.safetensors"
|
|
text_path = "../models/text_encoders/Qwen3-VL-4B-Instruct-Q4_K_M.gguf"
|
|
vision_path = "../models/text_encoders/Qwen3-VL-4B-Instruct-mmproj-BF16.gguf"
|
|
vae_path = "../models/vae/flux2_ae.safetensors"
|
|
|
|
output_path = "output.png"
|
|
|
|
prompt = "a lovely cat holding a sign says 'fibo2.cpp'"
|
|
negative_prompt = ""
|
|
|
|
seed = 42
|
|
rng_type = "cuda"
|
|
width = 512
|
|
height = 512
|
|
|
|
steps = 20
|
|
cfg_scale = 5.0
|
|
method = "euler"
|
|
scheduler = "flux"
|
|
}
|
|
|
|
fn main() {
|
|
model = load_dit(model_path, family = "fibo2", params_backend = "cpu")
|
|
text = load_text_encoder(text_path, family = "fibo2", params_backend = "cpu", vision_path = vision_path)
|
|
vae = load_vae(vae_path, family = "fibo2", params_backend = "cpu")
|
|
|
|
base = tensor::zeros(latent_shape(vae, width = width, height = height))
|
|
positive = encode_prompt(text, prompt, width = width, height = height)
|
|
negative = encode_prompt(text, negative_prompt, width = width, height = height)
|
|
pos = predictor(model, positive)
|
|
neg = predictor(model, negative)
|
|
guided = cfg(pos, neg, scale = cfg_scale)
|
|
sigmas = make_sigmas(guided, latent = base, steps = steps, scheduler = scheduler)
|
|
rng = make_rng(rng_type, seed = seed)
|
|
start = add_noise(guided, base, tensor::randn_like(base, rng = rng), sigma = sigmas[0])
|
|
latent = sample(start, sigmas, predict = guided, method = method, rng = rng)
|
|
image = vae_decode(vae, dit_to_vae_latents(vae, latent))
|
|
image::save(output_path, image)
|
|
return {image = image, latent = latent}
|
|
}
|