text stringlengths 0 5.54k |
|---|
The reference image to condition the generation on. condtioning_image (PIL.Image.Image) — |
The conditioning canny edge image to condition the generation on. source_subject_category (List[str]) — |
The source subject category. target_subject_category (List[str]) — |
The target subject category. latents (torch.FloatTensor, optional) — |
Pre-generated noisy latents, sampled from a Gaussian distribution, to be used as inputs for image |
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents |
tensor will ge generated by random sampling. guidance_scale (float, optional, defaults to 7.5) — |
Guidance scale as defined in Classifier-Free Diffusion Guidance. |
guidance_scale is defined as w of equation 2. of Imagen |
Paper. Guidance scale is enabled by setting guidance_scale > 1. Higher guidance scale encourages to generate images that are closely linked to the text prompt, |
usually at the expense of lower image quality. height (int, optional, defaults to 512) — |
The height of the generated image. width (int, optional, defaults to 512) — |
The width of the generated image. seed (int, optional, defaults to 42) — |
The seed to use for random generation. num_inference_steps (int, optional, defaults to 50) — |
The number of denoising steps. More denoising steps usually lead to a higher quality image at the |
expense of slower inference. generator (torch.Generator or List[torch.Generator], optional) — |
One or a list of torch generator(s) |
to make generation deterministic. neg_prompt (str, optional, defaults to "") — |
The prompt or prompts not to guide the image generation. Ignored when not using guidance (i.e., ignored |
if guidance_scale is less than 1). prompt_strength (float, optional, defaults to 1.0) — |
The strength of the prompt. Specifies the number of times the prompt is repeated along with prompt_reps |
to amplify the prompt. prompt_reps (int, optional, defaults to 20) — |
The number of times the prompt is repeated along with prompt_strength to amplify the prompt. Returns |
ImagePipelineOutput or tuple |
Function invoked when calling the pipeline for generation. Examples: Copied >>> from diffusers.pipelines import BlipDiffusionControlNetPipeline |
>>> from diffusers.utils import load_image |
>>> from controlnet_aux import CannyDetector |
>>> import torch |
>>> blip_diffusion_pipe = BlipDiffusionControlNetPipeline.from_pretrained( |
... "Salesforce/blipdiffusion-controlnet", torch_dtype=torch.float16 |
... ).to("cuda") |
>>> style_subject = "flower" |
>>> tgt_subject = "teapot" |
>>> text_prompt = "on a marble table" |
>>> cldm_cond_image = load_image( |
... "https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/kettle.jpg" |
... ).resize((512, 512)) |
>>> canny = CannyDetector() |
>>> cldm_cond_image = canny(cldm_cond_image, 30, 70, output_type="pil") |
>>> style_image = load_image( |
... "https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/flower.jpg" |
... ) |
>>> guidance_scale = 7.5 |
>>> num_inference_steps = 50 |
>>> negative_prompt = "over-exposure, under-exposure, saturated, duplicate, out of frame, lowres, cropped, worst quality, low quality, jpeg artifacts, morbid, mutilated, out of frame, ugly, bad anatomy, bad proportions, deformed, blurry, duplicate" |
>>> output = blip_diffusion_pipe( |
... text_prompt, |
... style_image, |
... cldm_cond_image, |
... style_subject, |
... tgt_subject, |
... guidance_scale=guidance_scale, |
... num_inference_steps=num_inference_steps, |
... neg_prompt=negative_prompt, |
... height=512, |
... width=512, |
... ).images |
>>> output[0].save("image.png") |
DPMSolverSinglestepScheduler DPMSolverSinglestepScheduler is a single step scheduler from DPM-Solver: A Fast ODE Solver for Diffusion Probabilistic Model Sampling in Around 10 Steps and DPM-Solver++: Fast Solver for Guided Sampling of Diffusion Probabilistic Models by Cheng Lu, Yuhao Zhou, Fan Bao, Jianfei Chen, Chongxuan Li, and Jun Zhu. DPMSolver (and the improved version DPMSolver++) is a fast dedicated high-order solver for diffusion ODEs with convergence order guarantee. Empirically, DPMSolver sampling with only 20 steps can generate high-quality |
samples, and it can generate quite good samples even in 10 steps. The original implementation can be found at LuChengTHU/dpm-solver. Tips It is recommended to set solver_order to 2 for guide sampling, and solver_order=3 for unconditional sampling. Dynamic thresholding from Imagen is supported, and for pixel-space |
diffusion models, you can set both algorithm_type="dpmsolver++" and thresholding=True to use dynamic |
thresholding. This thresholding method is unsuitable for latent-space diffusion models such as |
Stable Diffusion. DPMSolverSinglestepScheduler class diffusers.DPMSolverSinglestepScheduler < source > ( num_train_timesteps: int = 1000 beta_start: float = 0.0001 beta_end: float = 0.02 beta_schedule: str = 'linear' trained_betas: Optional = None solver_order: int = 2 prediction_type: str = 'epsilon' thresholding: bool = False dynamic_thresholding_ratio: float = 0.995 sample_max_value: float = 1.0 algorithm_type: str = 'dpmsolver++' solver_type: str = 'midpoint' lower_order_final: bool = False use_karras_sigmas: Optional = False final_sigmas_type: Optional = 'zero' lambda_min_clipped: float = -inf variance_type: Optional = None ) Parameters num_train_timesteps (int, defaults to 1000) — |
The number of diffusion steps to train the model. beta_start (float, defaults to 0.0001) — |
The starting beta value of inference. beta_end (float, defaults to 0.02) — |
The final beta value. beta_schedule (str, defaults to "linear") — |
The beta schedule, a mapping from a beta range to a sequence of betas for stepping the model. Choose from |
linear, scaled_linear, or squaredcos_cap_v2. trained_betas (np.ndarray, optional) — |
Pass an array of betas directly to the constructor to bypass beta_start and beta_end. solver_order (int, defaults to 2) — |
The DPMSolver order which can be 1 or 2 or 3. It is recommended to use solver_order=2 for guided |
sampling, and solver_order=3 for unconditional sampling. prediction_type (str, defaults to epsilon, optional) — |
Prediction type of the scheduler function; can be epsilon (predicts the noise of the diffusion process), |
sample (directly predicts the noisy sample) or v_prediction` (see section 2.4 of Imagen |
Video paper). thresholding (bool, defaults to False) — |
Whether to use the “dynamic thresholding” method. This is unsuitable for latent-space diffusion models such |
as Stable Diffusion. dynamic_thresholding_ratio (float, defaults to 0.995) — |
The ratio for the dynamic thresholding method. Valid only when thresholding=True. sample_max_value (float, defaults to 1.0) — |
The threshold value for dynamic thresholding. Valid only when thresholding=True and |
algorithm_type="dpmsolver++". algorithm_type (str, defaults to dpmsolver++) — |
Algorithm type for the solver; can be dpmsolver or dpmsolver++. The |
dpmsolver type implements the algorithms in the DPMSolver |
paper, and the dpmsolver++ type implements the algorithms in the |
DPMSolver++ paper. It is recommended to use dpmsolver++ or |
sde-dpmsolver++ with solver_order=2 for guided sampling like in Stable Diffusion. solver_type (str, defaults to midpoint) — |
Solver type for the second-order solver; can be midpoint or heun. The solver type slightly affects the |
sample quality, especially for a small number of steps. It is recommended to use midpoint solvers. lower_order_final (bool, defaults to True) — |
Whether to use lower-order solvers in the final steps. Only valid for < 15 inference steps. This can |
stabilize the sampling of DPMSolver for steps < 15, especially for steps <= 10. use_karras_sigmas (bool, optional, defaults to False) — |
Whether to use Karras sigmas for step sizes in the noise schedule during the sampling process. If True, |
the sigmas are determined according to a sequence of noise levels {σi}. final_sigmas_type (str, optional, defaults to "zero") — |
The final sigma value for the noise schedule during the sampling process. If "sigma_min", the final sigma |
is the same as the last sigma in the training schedule. If zero, the final sigma is set to 0. lambda_min_clipped (float, defaults to -inf) — |
Clipping threshold for the minimum value of lambda(t) for numerical stability. This is critical for the |
cosine (squaredcos_cap_v2) noise schedule. variance_type (str, optional) — |
Set to “learned” or “learned_range” for diffusion models that predict variance. If set, the model’s output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.