MCPcopy Create free account
hub / github.com/ali-vilab/ACE_plus / __call__

Method __call__

inference/ace_plus_diffusers.py:69–117  ·  view source on GitHub ↗
(self,
                 reference_image=None,
                 edit_image=None,
                 edit_mask=None,
                 prompt='',
                 task=None,
                 output_height=1024,
                 output_width=1024,
                 sampler='flow_euler',
                 sample_steps=28,
                 guide_scale=50,
                 lora_path=None,
                 seed=-1,
                 tar_index=0,
                 align=0,
                 repainting_scale=0,
                 **kwargs)

Source from the content-addressed store, hash-verified

67
68 @torch.no_grad()
69 def __call__(self,
70 reference_image=None,
71 edit_image=None,
72 edit_mask=None,
73 prompt='',
74 task=None,
75 output_height=1024,
76 output_width=1024,
77 sampler='flow_euler',
78 sample_steps=28,
79 guide_scale=50,
80 lora_path=None,
81 seed=-1,
82 tar_index=0,
83 align=0,
84 repainting_scale=0,
85 **kwargs):
86 if isinstance(prompt, str):
87 prompt = [prompt]
88 seed = seed if seed >= 0 else random.randint(0, 2 ** 32 - 1)
89 # edit_image, edit_mask, change_image, content_image, out_h, out_w, slice_w
90 image, mask, _, _, out_h, out_w, slice_w = self.image_processor.preprocess(reference_image, edit_image, edit_mask,
91 width = output_width,
92 height = output_height,
93 repainting_scale = repainting_scale)
94 h, w = image.shape[1:]
95 generator = torch.Generator("cpu").manual_seed(seed)
96 masked_image_latents = self.prepare_input(image, mask,
97 batch_size=len(prompt) , height=h, width=w, generator = generator)
98
99 if lora_path is not None:
100 with FS.get_from(lora_path) as local_path:
101 self.pipe.load_lora_weights(local_path)
102
103
104
105 image = self.pipe(
106 prompt=prompt,
107 masked_image_latents=masked_image_latents,
108 height=h,
109 width=w,
110 guidance_scale=guide_scale,
111 num_inference_steps=sample_steps,
112 max_sequence_length=512,
113 generator=generator
114 ).images[0]
115 if lora_path is not None:
116 self.pipe.unload_lora_weights()
117 return self.image_processor.postprocess(image, slice_w, out_w, out_h), seed
118
119
120if __name__ == '__main__':

Callers

nothing calls this directly

Calls 3

prepare_inputMethod · 0.95
postprocessMethod · 0.80
preprocessMethod · 0.45

Tested by

no test coverage detected