text
stringlengths
0
5.54k
... "https://raw.githubusercontent.com/Fantasy-Studio/Paint-by-Example/main/examples/mask/example_1.png"
... )
>>> example_url = "https://raw.githubusercontent.com/Fantasy-Studio/Paint-by-Example/main/examples/reference/example_1.jpg"
>>> init_image = download_image(img_url).resize((512, 512))
>>> mask_image = download_image(mask_url).resize((512, 512))
>>> example_image = download_image(example_url).resize((512, 512))
>>> pipe = PaintByExamplePipeline.from_pretrained(
... "Fantasy-Studio/Paint-by-Example",
... torch_dtype=torch.float16,
... )
>>> pipe = pipe.to("cuda")
>>> image = pipe(image=init_image, mask_image=mask_image, example_image=example_image).images[0]
>>> image StableDiffusionPipelineOutput class diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput < source > ( images: Union nsfw_content_detected: Optional ) Parameters images (List[PIL.Image.Image] or np.ndarray) β€”
List of denoised PIL images of length batch_size or NumPy array of shape (batch_size, height, width, num_channels). nsfw_content_detected (List[bool]) β€”
List indicating whether the corresponding generated image contains β€œnot-safe-for-work” (nsfw) content or
None if safety checking could not be performed. Output class for Stable Diffusion pipelines.
DEISMultistepScheduler Diffusion Exponential Integrator Sampler (DEIS) is proposed in Fast Sampling of Diffusion Models with Exponential Integrator by Qinsheng Zhang and Yongxin Chen. DEISMultistepScheduler is a fast high order solver for diffusion ordinary differential equations (ODEs). This implementation modifies th...
diffusion models, you can set thresholding=True to use the dynamic thresholding. DEISMultistepScheduler class diffusers.DEISMultistepScheduler < 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 ...
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 DEIS 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) β€”
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. algorithm_type (str, defaults to deis) β€”
The algorithm type for the solver. lower_order_final (bool, defaults to True) β€”
Whether to use lower-order solvers in the final steps. Only valid for < 15 inference steps. 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}. timestep_spacing (str, defaults to "linspace") β€”
The way the timesteps should be scaled. Refer to Table 2 of the Common Diffusion Noise Schedules and
Sample Steps are Flawed for more information. steps_offset (int, defaults to 0) β€”
An offset added to the inference steps. You can use a combination of offset=1 and
set_alpha_to_one=False to make the last step use step 0 for the previous alpha product like in Stable
Diffusion. DEISMultistepScheduler is a fast high order solver for diffusion ordinary differential equations (ODEs). This model inherits from SchedulerMixin and ConfigMixin. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving. convert_model_output < source > ( model_output: FloatTensor *args sample: FloatTensor = None **kwargs ) β†’ torch.FloatTensor Parameters model_output (torch.FloatTensor) β€”
The direct output from the learned diffusion model. timestep (int) β€”
The current discrete timestep in the diffusion chain. sample (torch.FloatTensor) β€”
A current instance of a sample created by the diffusion process. Returns
torch.FloatTensor
The converted model output.
Convert the model output to the corresponding type the DEIS algorithm needs. deis_first_order_update < source > ( model_output: FloatTensor *args sample: FloatTensor = None **kwargs ) β†’ torch.FloatTensor Parameters model_output (torch.FloatTensor) β€”
The direct output from the learned diffusion model. timestep (int) β€”
The current discrete timestep in the diffusion chain. prev_timestep (int) β€”
The previous discrete timestep in the diffusion chain. sample (torch.FloatTensor) β€”
A current instance of a sample created by the diffusion process. Returns
torch.FloatTensor
The sample tensor at the previous timestep.
One step for the first-order DEIS (equivalent to DDIM). multistep_deis_second_order_update < source > ( model_output_list: List *args sample: FloatTensor = None **kwargs ) β†’ torch.FloatTensor Parameters model_output_list (List[torch.FloatTensor]) β€”
The direct outputs from learned diffusion model at current and latter timesteps. sample (torch.FloatTensor) β€”
A current instance of a sample created by the diffusion process. Returns
torch.FloatTensor
The sample tensor at the previous timestep.
One step for the second-order multistep DEIS. multistep_deis_third_order_update < source > ( model_output_list: List *args sample: FloatTensor = None **kwargs ) β†’ torch.FloatTensor Parameters model_output_list (List[torch.FloatTensor]) β€”
The direct outputs from learned diffusion model at current and latter timesteps. sample (torch.FloatTensor) β€”
A current instance of a sample created by diffusion process. Returns
torch.FloatTensor
The sample tensor at the previous timestep.
One step for the third-order multistep DEIS. scale_model_input < source > ( sample: FloatTensor *args **kwargs ) β†’ torch.FloatTensor Parameters sample (torch.FloatTensor) β€”
The input sample. Returns
torch.FloatTensor
A scaled input sample.
Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep. set_begin_index < source > ( begin_index: int = 0 ) Parameters begin_index (int) β€”
The begin index for the scheduler. Sets the begin index for the scheduler. This function should be run from pipeline before the inference. set_timesteps < source > ( num_inference_steps: int device: Union = None ) Parameters num_inference_steps (int) β€”
The number of diffusion steps used when generating samples with a pre-trained model. device (str or torch.device, optional) β€”
The device to which the timesteps should be moved to. If None, the timesteps are not moved. Sets the discrete timesteps used for the diffusion chain (to be run before inference). step < source > ( model_output: FloatTensor timestep: int sample: FloatTensor return_dict: bool = True ) β†’ SchedulerOutput or tuple Pa...
The direct output from learned diffusion model. timestep (float) β€”
The current discrete timestep in the diffusion chain. sample (torch.FloatTensor) β€”
A current instance of a sample created by the diffusion process. return_dict (bool) β€”
Whether or not to return a SchedulerOutput or tuple. Returns
SchedulerOutput or tuple
If return_dict is True, SchedulerOutput is returned, otherwise a
tuple is returned where the first element is the sample tensor.
Predict the sample from the previous timestep by reversing the SDE. This function propagates the sample with
the multistep DEIS. SchedulerOutput class diffusers.schedulers.scheduling_utils.SchedulerOutput < source > ( prev_sample: FloatTensor ) Parameters prev_sample (torch.FloatTensor of shape (batch_size, num_channels, height, width) for images) β€”
Computed sample (x_{t-1}) of previous timestep. prev_sample should be used as next model input in the
denoising loop. Base class for the output of a scheduler’s step function.
Text-guided depth-to-image generation The StableDiffusionDepth2ImgPipeline lets you pass a text prompt and an initial image to condition the generation of new images. In addition, you can also pass a depth_map to preserve the image structure. If no depth_map is provided, the pipeline automatically predicts t...
from diffusers import StableDiffusionDepth2ImgPipeline
from diffusers.utils import load_image, make_image_grid
pipeline = StableDiffusionDepth2ImgPipeline.from_pretrained(
"stabilityai/stable-diffusion-2-depth",