mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
95954188b2
Factory pattern is now removed. Typical usage of the InvokeAIGenerator is now: ``` from invokeai.backend.generator import ( InvokeAIGeneratorBasicParams, Txt2Img, Img2Img, Inpaint, ) params = InvokeAIGeneratorBasicParams( model_name = 'stable-diffusion-1.5', steps = 30, scheduler = 'k_lms', cfg_scale = 8.0, height = 640, width = 640 ) print ('=== TXT2IMG TEST ===') txt2img = Txt2Img(manager, params) outputs = txt2img.generate(prompt='banana sushi', iterations=2) for i in outputs: print(f'image={output.image}, seed={output.seed}, model={output.params.model_name}, hash={output.model_hash}, steps={output.params.steps}') ``` The `params` argument is optional, so if you wish to accept default parameters and selectively override them, just do this: ``` outputs = Txt2Img(manager).generate(prompt='banana sushi', steps=50, scheduler='k_heun', model_name='stable-diffusion-2.1' ) ```
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654)
|
|
from invokeai.backend import ModelManager
|
|
|
|
from .events import EventServiceBase
|
|
from .image_storage import ImageStorageBase
|
|
from .invocation_queue import InvocationQueueABC
|
|
from .item_storage import ItemStorageABC
|
|
|
|
|
|
class InvocationServices:
|
|
"""Services that can be used by invocations"""
|
|
|
|
model_manager: ModelManager
|
|
events: EventServiceBase
|
|
images: ImageStorageBase
|
|
queue: InvocationQueueABC
|
|
|
|
# NOTE: we must forward-declare any types that include invocations, since invocations can use services
|
|
graph_execution_manager: ItemStorageABC["GraphExecutionState"]
|
|
processor: "InvocationProcessorABC"
|
|
|
|
def __init__(
|
|
self,
|
|
model_manager: ModelManager,
|
|
events: EventServiceBase,
|
|
images: ImageStorageBase,
|
|
queue: InvocationQueueABC,
|
|
graph_execution_manager: ItemStorageABC["GraphExecutionState"],
|
|
processor: "InvocationProcessorABC",
|
|
):
|
|
self.model_manager = model_manager
|
|
self.events = events
|
|
self.images = images
|
|
self.queue = queue
|
|
self.graph_execution_manager = graph_execution_manager
|
|
self.processor = processor
|