Commit 1b57ae00 authored by Your Name's avatar Your Name

fix: use generate_image instead of generate for stable-diffusion-cpp

parent 8092e302
Help on function generate_image in module stable_diffusion_cpp.stable_diffusion:
generate_image(
self,
prompt: str,
negative_prompt: str = '',
clip_skip: int = -1,
init_image: Union[PIL.Image.Image, str, NoneType] = None,
ref_images: Optional[List[Union[PIL.Image.Image, str]]] = None,
auto_resize_ref_image: bool = True,
increase_ref_index: bool = False,
mask_image: Union[PIL.Image.Image, str, NoneType] = None,
width: int = 512,
height: int = 512,
cfg_scale: float = 7.0,
image_cfg_scale: Optional[float] = None,
guidance: float = 3.5,
scheduler: Union[str, stable_diffusion_cpp.stable_diffusion_cpp.Scheduler, int, float, NoneType] = 'default',
sample_method: Union[str, stable_diffusion_cpp.stable_diffusion_cpp.SampleMethod, int, float, NoneType] = 'default',
sample_steps: int = 20,
eta: float = 0.0,
timestep_shift: int = 0,
sigmas: Optional[str] = None,
skip_layers: List[int] = [7, 8, 9],
skip_layer_start: float = 0.01,
skip_layer_end: float = 0.2,
slg_scale: float = 0.0,
strength: float = 0.75,
seed: int = 42,
batch_count: int = 1,
control_image: Union[PIL.Image.Image, str, NoneType] = None,
control_strength: float = 0.9,
pm_id_embed_path: str = '',
pm_id_images: Optional[List[Union[PIL.Image.Image, str]]] = None,
pm_style_strength: float = 20.0,
vae_tiling: bool = False,
vae_tile_overlap: float = 0.5,
vae_tile_size: Union[int, str, NoneType] = '0x0',
vae_relative_tile_size: Union[float, str, NoneType] = '0x0',
cache_mode: Union[str, stable_diffusion_cpp.stable_diffusion_cpp.SDCacheMode, int, float, NoneType] = 'disabled',
cache_reuse_threshold: float = 1.0,
cache_start_percent: float = 0.15,
cache_end_percent: float = 0.95,
cache_error_decay_rate: float = 1.0,
cache_use_relative_threshold: bool = True,
cache_reset_error_on_compute: bool = True,
cache_Fn_compute_blocks: int = 8,
cache_Bn_compute_blocks: int = 0,
cache_residual_diff_threshold: float = 0.08,
cache_max_warmup_steps: int = 8,
cache_max_continuous_cached_steps: int = -1,
cache_taylorseer_n_derivatives: int = 1,
cache_taylorseer_skip_interval: int = 1,
scm_mask: str = '',
scm_policy: Literal['dynamic', 'static'] = 'dynamic',
canny: bool = False,
upscale_factor: int = 1,
preview_method: Union[str, stable_diffusion_cpp.stable_diffusion_cpp.Preview, int, float] = 'none',
preview_noisy: bool = False,
preview_interval: int = 1,
preview_callback: Optional[Callable] = None,
progress_callback: Optional[Callable] = None
) -> List[PIL.Image.Image]
Generate images from a text prompt and or input images.
Args:
prompt: The prompt to render.
negative_prompt: The negative prompt.
clip_skip: Ignore last layers of CLIP network (1 ignores none, 2 ignores one layer, <= 0 represents unspecified, will be 1 for SD1.x, 2 for SD2.x).
init_image: An input image path or Pillow Image to direct the generation.
ref_images: A list of input image paths or Pillow Images for Flux Kontext models (can be used multiple times).
auto_resize_ref_image: Automatically resize reference images.
increase_ref_index: Automatically increase the indices of reference images based on the order they are listed (starting with 1).
mask_image: The inpainting mask image path or Pillow Image.
width: Image width, in pixel space.
height: Image height, in pixel space.
cfg_scale: Unconditional guidance scale.
image_cfg_scale: Image guidance scale for inpaint or instruct-pix2pix models.
guidance: Distilled guidance scale for models with guidance input.
scheduler: Denoiser sigma scheduler (default: discrete).
sample_method: Sampling method (default: euler for Flux/SD3/Wan, euler_a otherwise).
sample_steps: Number of sample steps.
eta: Eta in DDIM, only for DDIM and TCD.
timestep_shift: Shift timestep for NitroFusion models, default: 0, recommended N for NitroSD-Realism around 250 and 500 for NitroSD-Vibrant.
sigmas: Custom sigma values for the sampler, comma-separated (e.g. "14.61,7.8,3.5,0.0").
skip_layers: Layers to skip for SLG steps (SLG will be enabled at step int([STEPS]x[START]) and disabled at int([STEPS]x[END])).
skip_layer_start: SLG enabling point.
skip_layer_end: SLG disabling point.
slg_scale: Skip layer guidance (SLG) scale, only for DiT models.
strength: Strength for noising/unnoising.
seed: RNG seed (uses random seed for < 0).
batch_count: Number of images to generate.
control_image: A control condition image path or Pillow Image (Control Net).
control_strength: Strength to apply Control Net.
pm_id_embed_path: Path to PhotoMaker v2 id embed.
pm_id_images: A list of input image paths or Pillow Images for PhotoMaker input identity.
pm_style_strength: Strength for keeping PhotoMaker input identity.
vae_tiling: Process vae in tiles to reduce memory usage.
vae_tile_overlap: Tile overlap for vae tiling, in fraction of tile size.
vae_tile_size: Tile size for vae tiling ([X]x[Y] format).
vae_relative_tile_size: Relative tile size for vae tiling, in fraction of image size if < 1, in number of tiles per dim if >=1 ([X]x[Y] format) (overrides `vae_tile_size`).
cache_mode: The caching method to use (default: disabled).
scm_mask: SCM steps mask for cache-dit: comma-separated 0/1 (e.g., "1,1,1,0,0,1,0,0,1,0") - 1=compute, 0=can cache.
scm_policy: SCM policy 'dynamic' or 'static'.
canny: Apply canny edge detection preprocessor to the `control_image`.
upscale_factor: Run the ESRGAN upscaler this many times.
preview_method: The preview method to use (default: none).
preview_noisy: Enables previewing noisy inputs of the models rather than the denoised outputs.
preview_interval: Interval in denoising steps between consecutive updates of the image preview (default: 1, meaning update at every step)
preview_callback: Callback function to call on each preview frame.
progress_callback: Callback function to call on each step end.
Returns:
A list of Pillow Images.
...@@ -3189,12 +3189,15 @@ async def create_image_generation(request: ImageGenerationRequest): ...@@ -3189,12 +3189,15 @@ async def create_image_generation(request: ImageGenerationRequest):
steps = request.steps if request.steps else 4 steps = request.steps if request.steps else 4
# Generate images using sd.cpp # Generate images using sd.cpp
result = sd_model.generate( result = sd_model.generate_image(
prompt=request.prompt, prompt=request.prompt,
negative_prompt='',
width=width, width=width,
height=height, height=height,
cfg_scale=7.0,
sample_steps=steps, sample_steps=steps,
n=request.n if request.n else 1, seed=42,
batch_count=request.n if request.n else 1,
) )
# Convert results to response format # Convert results to response format
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment