text
stringlengths
0
5.54k
negative_prompt="extra digit, fewer digits, cropped, worst quality, low quality",
image=sketch_image,
generator=generator,
guidance_scale=7.5
).images[0]
make_image_grid([sketch_image, sketch_image_out], rows=1, cols=2) Available checkpoints Non-diffusers checkpoints can be found under TencentARC/T2I-Adapter. T2I-Adapter with Stable Diffusion 1.4 Model Name Control Image Overview Control Image Example Generated Image Example TencentARC/t2iadapter_color_sd14v1 Trained...
cond_keypose = load_image(
"https://huggingface.co/datasets/diffusers/docs-images/resolve/main/t2i-adapter/keypose_sample_input.png"
)
cond_depth = load_image(
"https://huggingface.co/datasets/diffusers/docs-images/resolve/main/t2i-adapter/depth_sample_input.png"
)
cond = [cond_keypose, cond_depth]
prompt = ["A man walking in an office room with a nice view"] The two control images look as such: MultiAdapter combines keypose and depth adapters. adapter_conditioning_scale balances the relative influence of the different adapters. Copied import torch
from diffusers import StableDiffusionAdapterPipeline, MultiAdapter, T2IAdapter
adapters = MultiAdapter(
[
T2IAdapter.from_pretrained("TencentARC/t2iadapter_keypose_sd14v1"),
T2IAdapter.from_pretrained("TencentARC/t2iadapter_depth_sd14v1"),
]
)
adapters = adapters.to(torch.float16)
pipe = StableDiffusionAdapterPipeline.from_pretrained(
"CompVis/stable-diffusion-v1-4",
torch_dtype=torch.float16,
adapter=adapters,
).to("cuda")
image = pipe(prompt, cond, adapter_conditioning_scale=[0.8, 0.8]).images[0]
make_image_grid([cond_keypose, cond_depth, image], rows=1, cols=3) T2I-Adapter vs ControlNet T2I-Adapter is similar to ControlNet.
T2I-Adapter uses a smaller auxiliary network which is only run once for the entire diffusion process.
However, T2I-Adapter performs slightly worse than ControlNet. StableDiffusionAdapterPipeline class diffusers.StableDiffusionAdapterPipeline < source > ( vae: AutoencoderKL text_encoder: CLIPTextModel tokenizer: CLIPTokenizer unet: UNet2DConditionModel adapter: Union scheduler: KarrasDiffusionSchedulers safety_checke...
Provides additional conditioning to the unet during the denoising process. If you set multiple Adapter as a
list, the outputs from each Adapter are added together to create one combined additional conditioning. adapter_weights (List[float], optional, defaults to None) β€”
List of floats representing the weight which will be multiply to each adapter’s output before adding them
together. vae (AutoencoderKL) β€”
Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations. text_encoder (CLIPTextModel) β€”
Frozen text-encoder. Stable Diffusion uses the text portion of
CLIP, specifically
the clip-vit-large-patch14 variant. tokenizer (CLIPTokenizer) β€”
Tokenizer of class
CLIPTokenizer. unet (UNet2DConditionModel) β€” Conditional U-Net architecture to denoise the encoded image latents. scheduler (SchedulerMixin) β€”
A scheduler to be used in combination with unet to denoise the encoded image latents. Can be one of
DDIMScheduler, LMSDiscreteScheduler, or PNDMScheduler. safety_checker (StableDiffusionSafetyChecker) β€”
Classification module that estimates whether generated images could be considered offensive or harmful.
Please, refer to the model card for details. feature_extractor (CLIPFeatureExtractor) β€”
Model that extracts features from generated images to be used as inputs for the safety_checker. Pipeline for text-to-image generation using Stable Diffusion augmented with T2I-Adapter
https://arxiv.org/abs/2302.08453 This model inherits from DiffusionPipeline. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.) __call__ < source > ( prompt: Union = None image: Union = None height: Optional = None width: Optional = None num_inference_steps: int = 50 timesteps: List = None guidance_scale: float = 7.5 negative_prompt:...
The prompt or prompts to guide the image generation. If not defined, one has to pass prompt_embeds.
instead. image (torch.FloatTensor, PIL.Image.Image, List[torch.FloatTensor] or List[PIL.Image.Image] or List[List[PIL.Image.Image]]) β€”
The Adapter input condition. Adapter uses this input condition to generate guidance to Unet. If the
type is specified as Torch.FloatTensor, it is passed to Adapter as is. PIL.Image.Image` can also be
accepted as an image. The control image is automatically resized to fit the output image. height (int, optional, defaults to self.unet.config.sample_size * self.vae_scale_factor) β€”
The height in pixels of the generated image. width (int, optional, defaults to self.unet.config.sample_size * self.vae_scale_factor) β€”
The width in pixels of the generated image. 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. timesteps (List[int], optional) β€”
Custom timesteps to use for the denoising process with schedulers which support a timesteps argument
in their set_timesteps method. If not defined, the default behavior when num_inference_steps is
passed will be used. Must be in descending order. 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. negative_prompt (str or List[str], optional) β€”
The prompt or prompts not to guide the image generation. If not defined, one has to pass
negative_prompt_embeds. instead. If not defined, one has to pass negative_prompt_embeds. instead.
Ignored when not using guidance (i.e., ignored if guidance_scale is less than 1). num_images_per_prompt (int, optional, defaults to 1) β€”
The number of images to generate per prompt. eta (float, optional, defaults to 0.0) β€”
Corresponds to parameter eta (Ξ·) in the DDIM paper: https://arxiv.org/abs/2010.02502. Only applies to
schedulers.DDIMScheduler, will be ignored for others. generator (torch.Generator or List[torch.Generator], optional) β€”
One or a list of torch generator(s)
to make generation deterministic. 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 sampling using the supplied random generator. prompt_embeds (torch.FloatTensor, optional) β€”
Pre-generated text embeddings. Can be used to easily tweak text inputs, e.g. prompt weighting. If not
provided, text embeddings will be generated from prompt input argument. negative_prompt_embeds (torch.FloatTensor, optional) β€”
Pre-generated negative text embeddings. Can be used to easily tweak text inputs, e.g. prompt
weighting. If not provided, negative_prompt_embeds will be generated from negative_prompt input
argument. output_type (str, optional, defaults to "pil") β€”
The output format of the generate image. Choose between
PIL: PIL.Image.Image or np.array. return_dict (bool, optional, defaults to True) β€”
Whether or not to return a ~pipelines.stable_diffusion.StableDiffusionAdapterPipelineOutput instead
of a plain tuple. callback (Callable, optional) β€”
A function that will be called every callback_steps steps during inference. The function will be
called with the following arguments: callback(step: int, timestep: int, latents: torch.FloatTensor). callback_steps (int, optional, defaults to 1) β€”
The frequency at which the callback function will be called. If not specified, the callback will be
called at every step. cross_attention_kwargs (dict, optional) β€”
A kwargs dictionary that if specified is passed along to the AttnProcessor as defined under
self.processor in
diffusers.models.attention_processor. adapter_conditioning_scale (float or List[float], optional, defaults to 1.0) β€”
The outputs of the adapter are multiplied by adapter_conditioning_scale before they are added to the
residual in the original unet. If multiple adapters are specified in init, you can set the
corresponding scale as a list. clip_skip (int, optional) β€”
Number of layers to be skipped from CLIP while computing the prompt embeddings. A value of 1 means that