mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
make step_callback work again in generate() call
This PR fixes #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() ```
This commit is contained in:
parent
f2efde27f6
commit
f329fddab9
@ -10,6 +10,7 @@ from .generator import (
|
||||
Img2Img,
|
||||
Inpaint
|
||||
)
|
||||
from .stable_diffusion.diffusers_pipeline import PipelineIntermediateState
|
||||
from .model_management import ModelManager
|
||||
from .safety_checker import SafetyChecker
|
||||
from .args import Args
|
||||
|
@ -154,6 +154,7 @@ class InvokeAIGenerator(metaclass=ABCMeta):
|
||||
for i in iteration_count:
|
||||
results = generator.generate(prompt,
|
||||
conditioning=(uc, c, extra_conditioning_info),
|
||||
step_callback=step_callback,
|
||||
sampler=scheduler,
|
||||
**generator_args,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user