MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / __call__

Method __call__

diffusers/examples/community/sde_drag.py:63–205  ·  view source on GitHub ↗

r""" Function invoked when calling the pipeline for image editing. Args: prompt (`str`, *required*): The prompt to guide the image editing. image (`PIL.Image.Image`, *required*): Which will be edited, parts of the image will be

(
        self,
        prompt: str,
        image: PIL.Image.Image,
        mask_image: PIL.Image.Image,
        source_points: List[List[int]],
        target_points: List[List[int]],
        t0: Optional[float] = 0.6,
        steps: Optional[int] = 200,
        step_size: Optional[int] = 2,
        image_scale: Optional[float] = 0.3,
        adapt_radius: Optional[int] = 5,
        min_lora_scale: Optional[float] = 0.5,
        generator: Optional[torch.Generator] = None,
    )

Source from the content-addressed store, hash-verified

61
62 @torch.no_grad()
63 def __call__(
64 self,
65 prompt: str,
66 image: PIL.Image.Image,
67 mask_image: PIL.Image.Image,
68 source_points: List[List[int]],
69 target_points: List[List[int]],
70 t0: Optional[float] = 0.6,
71 steps: Optional[int] = 200,
72 step_size: Optional[int] = 2,
73 image_scale: Optional[float] = 0.3,
74 adapt_radius: Optional[int] = 5,
75 min_lora_scale: Optional[float] = 0.5,
76 generator: Optional[torch.Generator] = None,
77 ):
78 r"""
79 Function invoked when calling the pipeline for image editing.
80 Args:
81 prompt (`str`, *required*):
82 The prompt to guide the image editing.
83 image (`PIL.Image.Image`, *required*):
84 Which will be edited, parts of the image will be masked out with `mask_image` and edited
85 according to `prompt`.
86 mask_image (`PIL.Image.Image`, *required*):
87 To mask `image`. White pixels in the mask will be edited, while black pixels will be preserved.
88 source_points (`List[List[int]]`, *required*):
89 Used to mark the starting positions of drag editing in the image, with each pixel represented as a
90 `List[int]` of length 2.
91 target_points (`List[List[int]]`, *required*):
92 Used to mark the target positions of drag editing in the image, with each pixel represented as a
93 `List[int]` of length 2.
94 t0 (`float`, *optional*, defaults to 0.6):
95 The time parameter. Higher t0 improves the fidelity while lowering the faithfulness of the edited images
96 and vice versa.
97 steps (`int`, *optional*, defaults to 200):
98 The number of sampling iterations.
99 step_size (`int`, *optional*, defaults to 2):
100 The drag diatance of each drag step.
101 image_scale (`float`, *optional*, defaults to 0.3):
102 To avoid duplicating the content, use image_scale to perturbs the source.
103 adapt_radius (`int`, *optional*, defaults to 5):
104 The size of the region for copy and paste operations during each step of the drag process.
105 min_lora_scale (`float`, *optional*, defaults to 0.5):
106 A lora scale that will be applied to all LoRA layers of the text encoder if LoRA layers are loaded.
107 min_lora_scale specifies the minimum LoRA scale during the image drag-editing process.
108 generator ('torch.Generator', *optional*, defaults to None):
109 To make generation deterministic(https://pytorch.org/docs/stable/generated/torch.Generator.html).
110 Examples:
111 ```py
112 >>> import PIL
113 >>> import torch
114 >>> from diffusers import DDIMScheduler, DiffusionPipeline
115
116 >>> # Load the pipeline
117 >>> model_path = "runwayml/stable-diffusion-v1-5"
118 >>> scheduler = DDIMScheduler.from_pretrained(model_path, subfolder="scheduler")
119 >>> pipe = DiffusionPipeline.from_pretrained(model_path, scheduler=scheduler, custom_pipeline="sde_drag")
120 >>> pipe.to('cuda')

Callers

nothing calls this directly

Calls 9

_get_text_embedMethod · 0.95
_get_img_latentMethod · 0.95
_forwardMethod · 0.95
_copy_and_pasteMethod · 0.95
_backwardMethod · 0.95
set_timestepsMethod · 0.45
resizeMethod · 0.45
toMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected