Skip to content

Commit d117251

Browse files
lsteinebr
authored andcommitted
make step_callback work again in generate() call
This PR fixes invoke-ai#2951 and restores the step_callback argument in the refactored generate() method. Note that this issue states that "something is still wrong because steps and step are zero." However, I think this is confusion over the call signature of the callback, which since the diffusers merge has been `callback(state:PipelineIntermediateState)` This is the test script that I used to determine that `step` is being passed correctly: ``` from pathlib import Path from invokeai.backend import ModelManager, PipelineIntermediateState from invokeai.backend.globals import global_config_dir from invokeai.backend.generator import Txt2Img def my_callback(state:PipelineIntermediateState, total_steps:int): print(f'callback(step={state.step}/{total_steps})') def main(): manager = ModelManager(Path(global_config_dir()) / "models.yaml") model = manager.get_model('stable-diffusion-1.5') print ('=== TXT2IMG TEST ===') steps=30 output = next(Txt2Img(model).generate(prompt='banana sushi', iterations=None, steps=steps, step_callback=lambda x: my_callback(x,steps) ) ) print(f'image={output.image}, seed={output.seed}, steps={output.params.steps}') if __name__=='__main__': main() ```
1 parent 6ea61a8 commit d117251

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

invokeai/backend/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Img2Img,
1111
Inpaint
1212
)
13+
from .stable_diffusion.diffusers_pipeline import PipelineIntermediateState
1314
from .model_management import ModelManager
1415
from .safety_checker import SafetyChecker
1516
from .args import Args

0 commit comments

Comments
 (0)