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

Method callback_fn

diffusers/src/diffusers/callbacks.py:79–95  ·  view source on GitHub ↗
(self, pipeline, step_index, timestep, callback_kwargs)

Source from the content-addressed store, hash-verified

77 tensor_inputs = ["prompt_embeds"]
78
79 def callback_fn(self, pipeline, step_index, timestep, callback_kwargs) -> Dict[str, Any]:
80 cutoff_step_ratio = self.config.cutoff_step_ratio
81 cutoff_step_index = self.config.cutoff_step_index
82
83 # Use cutoff_step_index if it's not None, otherwise use cutoff_step_ratio
84 cutoff_step = (
85 cutoff_step_index if cutoff_step_index is not None else int(pipeline.num_timesteps * cutoff_step_ratio)
86 )
87
88 if step_index == cutoff_step:
89 prompt_embeds = callback_kwargs[self.tensor_inputs[0]]
90 prompt_embeds = prompt_embeds[-1:] # "-1" denotes the embeddings for conditional text tokens.
91
92 pipeline._guidance_scale = 0.0
93
94 callback_kwargs[self.tensor_inputs[0]] = prompt_embeds
95 return callback_kwargs
96
97
98class SDXLCFGCutoffCallback(PipelineCallback):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected