@@ -265,7 +265,7 @@ stable_diffusion = StableDiffusion(
265265 model_path="../models/v1-5-pruned-emaonly.safetensors",
266266 # wtype="default", # Weight type (e.g. "q8_0", "f16", etc) (The "default" setting is automatically applied and determines the weight type of a model file)
267267)
268- output = stable_diffusion.txt_to_img (
268+ output = stable_diffusion.generate_image (
269269 prompt="a lovely cat",
270270 width=512, # Must be a multiple of 64
271271 height=512, # Must be a multiple of 64
@@ -291,7 +291,7 @@ stable_diffusion = StableDiffusion(
291291 model_path=" ../models/v1-5-pruned-emaonly.safetensors" ,
292292 lora_model_dir=" ../models/" , # This should point to folder where LoRA weights are stored (not an individual file)
293293)
294- output = stable_diffusion.txt_to_img (
294+ output = stable_diffusion.generate_image (
295295 prompt=" a lovely cat<lora:marblesh:1>" ,
296296)
297297` ` `
@@ -319,9 +319,9 @@ stable_diffusion = StableDiffusion(
319319 clip_l_path="../models/clip_l.safetensors",
320320 t5xxl_path="../models/t5xxl_fp16.safetensors",
321321 vae_path="../models/ae.safetensors",
322- vae_decode_only=True, # Can be True if we dont use img_to_img
322+ vae_decode_only=True, # Can be True if not generating image to image
323323)
324- output = stable_diffusion.txt_to_img (
324+ output = stable_diffusion.generate_image (
325325 prompt="a lovely cat holding a sign says ' flux.cpp' ",
326326 sample_steps=4,
327327 cfg_scale=1.0, # a cfg_scale of 1 is recommended for FLUX
@@ -357,7 +357,7 @@ stable_diffusion = StableDiffusion(
357357 vae_path="../models/ae.safetensors",
358358 vae_decode_only=False, # Must be False for FLUX Kontext
359359)
360- output = stable_diffusion.edit (
360+ output = stable_diffusion.generate_image (
361361 prompt="make the cat blue",
362362 images=["input.png"],
363363 cfg_scale=1.0, # a cfg_scale of 1 is recommended for FLUX
@@ -380,9 +380,9 @@ stable_diffusion = StableDiffusion(
380380 diffusion_model_path=" ../models/chroma-unlocked-v40-Q4_0.gguf" , # In place of model_path
381381 t5xxl_path=" ../models/t5xxl_fp16.safetensors" ,
382382 vae_path=" ../models/ae.safetensors" ,
383- vae_decode_only=True, # Can be True if we dont use img_to_img
383+ vae_decode_only=True, # Can be True if we are not generating image to image
384384)
385- output = stable_diffusion.txt_to_img (
385+ output = stable_diffusion.generate_image (
386386 prompt=" a lovely cat holding a sign says 'chroma.cpp'" ,
387387 sample_steps=4,
388388 cfg_scale=4.0, # a cfg_scale of 4 is recommended for Chroma
@@ -410,7 +410,7 @@ stable_diffusion = StableDiffusion(
410410 clip_g_path=" ../models/clip_g.safetensors" ,
411411 t5xxl_path=" ../models/t5xxl_fp16.safetensors" ,
412412)
413- output = stable_diffusion.txt_to_img (
413+ output = stable_diffusion.generate_image (
414414 prompt=" a lovely cat holding a sign says 'Stable diffusion 3.5 Large'" ,
415415 height=1024,
416416 width=1024,
@@ -432,9 +432,9 @@ INPUT_IMAGE = "../input.png"
432432
433433stable_diffusion = StableDiffusion(model_path=" ../models/v1-5-pruned-emaonly.safetensors" )
434434
435- output = stable_diffusion.img_to_img (
435+ output = stable_diffusion.generate_image (
436436 prompt=" blue eyes" ,
437- image =INPUT_IMAGE, # Note: The input image will be automatically resized to the match the width and height arguments (default: 512x512)
437+ init_image =INPUT_IMAGE, # Note: The input image will be automatically resized to the match the width and height arguments (default: 512x512)
438438 strength=0.4,
439439)
440440` ` `
@@ -447,9 +447,9 @@ from stable_diffusion_cpp import StableDiffusion
447447# Note: Inpainting with a base model gives poor results. A model fine-tuned for inpainting is recommended.
448448stable_diffusion = StableDiffusion(model_path=" ../models/v1-5-pruned-emaonly.safetensors" )
449449
450- output = stable_diffusion.img_to_img (
450+ output = stable_diffusion.generate_image (
451451 prompt=" blue eyes" ,
452- image =" ../input.png" ,
452+ init_image =" ../input.png" ,
453453 mask_image=" ../mask.png" , # A grayscale image where 0 is masked and 255 is unmasked
454454 strength=0.4,
455455)
@@ -478,7 +478,7 @@ stable_diffusion = StableDiffusion(
478478 # keep_vae_on_cpu=True, # If on low memory GPUs (<= 8GB), setting this to True is recommended to get artifact free images
479479)
480480
481- output = stable_diffusion.txt_to_img (
481+ output = stable_diffusion.generate_image (
482482 cfg_scale=5.0, # a cfg_scale of 5.0 is recommended for PhotoMaker
483483 height=1024,
484484 width=1024,
@@ -553,6 +553,15 @@ c_image = sd_cpp.sd_image_t(
553553 ctypes.POINTER(ctypes.c_uint8),
554554 ),
555555) # Create a new C sd_image_t
556+
557+ # Convert a model from safetensors to gguf format
558+ sd_cpp.convert(
559+ "../models/v1-5-pruned-emaonly.safetensors".encode("utf-8"), # input_path
560+ "".encode("utf-8"), # vae_path
561+ "../models/v1-5-pruned-emaonly.gguf".encode("utf-8"), # output_path
562+ sd_cpp.GGMLType.SD_TYPE_Q8_0, # output_type
563+ "".encode("utf-8"), # tensor_type_rules
564+ )
556565` ` `
557566
558567# # Development
0 commit comments