feat(nodes): create invocation_api.py

This is the public API for invocations.

Everything a custom node might need should be re-exported from this file.
This commit is contained in:
psychedelicious 2024-01-15 10:48:33 +11:00
parent 3de4390711
commit a7e23af9c6
7 changed files with 116 additions and 9 deletions

View File

@ -25,8 +25,7 @@ from controlnet_aux.util import HWC3, ade_palette
from PIL import Image from PIL import Image
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
from invokeai.app.invocations.baseinvocation import WithMetadata from invokeai.app.invocations.fields import FieldDescriptions, ImageField, Input, InputField, OutputField, WithMetadata
from invokeai.app.invocations.fields import FieldDescriptions, ImageField, Input, InputField, OutputField
from invokeai.app.invocations.primitives import ImageOutput from invokeai.app.invocations.primitives import ImageOutput
from invokeai.app.invocations.util import validate_begin_end_step, validate_weights from invokeai.app.invocations.util import validate_begin_end_step, validate_weights
from invokeai.backend.image_util.depth_anything import DepthAnythingDetector from invokeai.backend.image_util.depth_anything import DepthAnythingDetector

View File

@ -13,11 +13,10 @@ from pydantic import field_validator
import invokeai.assets.fonts as font_assets import invokeai.assets.fonts as font_assets
from invokeai.app.invocations.baseinvocation import ( from invokeai.app.invocations.baseinvocation import (
BaseInvocation, BaseInvocation,
WithMetadata,
invocation, invocation,
invocation_output, invocation_output,
) )
from invokeai.app.invocations.fields import ImageField, InputField, OutputField from invokeai.app.invocations.fields import ImageField, InputField, OutputField, WithMetadata
from invokeai.app.invocations.primitives import ImageOutput from invokeai.app.invocations.primitives import ImageOutput
from invokeai.app.services.image_records.image_records_common import ImageCategory from invokeai.app.services.image_records.image_records_common import ImageCategory

View File

@ -7,7 +7,6 @@ import cv2
import numpy import numpy
from PIL import Image, ImageChops, ImageFilter, ImageOps from PIL import Image, ImageChops, ImageFilter, ImageOps
from invokeai.app.invocations.baseinvocation import WithMetadata
from invokeai.app.invocations.fields import ( from invokeai.app.invocations.fields import (
BoardField, BoardField,
ColorField, ColorField,
@ -15,6 +14,7 @@ from invokeai.app.invocations.fields import (
ImageField, ImageField,
Input, Input,
InputField, InputField,
WithMetadata,
) )
from invokeai.app.invocations.primitives import ImageOutput from invokeai.app.invocations.primitives import ImageOutput
from invokeai.app.services.image_records.image_records_common import ImageCategory from invokeai.app.services.image_records.image_records_common import ImageCategory

View File

@ -13,8 +13,8 @@ from invokeai.backend.image_util.cv2_inpaint import cv2_inpaint
from invokeai.backend.image_util.lama import LaMA from invokeai.backend.image_util.lama import LaMA
from invokeai.backend.image_util.patchmatch import PatchMatch from invokeai.backend.image_util.patchmatch import PatchMatch
from .baseinvocation import BaseInvocation, WithMetadata, invocation from .baseinvocation import BaseInvocation, invocation
from .fields import InputField from .fields import InputField, WithMetadata
from .image import PIL_RESAMPLING_MAP, PIL_RESAMPLING_MODES from .image import PIL_RESAMPLING_MAP, PIL_RESAMPLING_MODES

View File

@ -8,11 +8,10 @@ from invokeai.app.invocations.baseinvocation import (
BaseInvocation, BaseInvocation,
BaseInvocationOutput, BaseInvocationOutput,
Classification, Classification,
WithMetadata,
invocation, invocation,
invocation_output, invocation_output,
) )
from invokeai.app.invocations.fields import ImageField, Input, InputField, OutputField from invokeai.app.invocations.fields import ImageField, Input, InputField, OutputField, WithMetadata
from invokeai.app.invocations.primitives import ImageOutput from invokeai.app.invocations.primitives import ImageOutput
from invokeai.backend.tiles.tiles import ( from invokeai.backend.tiles.tiles import (
calc_tiles_even_split, calc_tiles_even_split,

View File

@ -0,0 +1,109 @@
"""
This file re-exports all the public API for invocations. This is the only file that should be imported by custom nodes.
TODO(psyche): Do we want to dogfood this?
"""
from invokeai.app.invocations.baseinvocation import (
BaseInvocation,
BaseInvocationOutput,
invocation,
invocation_output,
)
from invokeai.app.invocations.fields import (
BoardField,
ColorField,
ConditioningField,
DenoiseMaskField,
FieldDescriptions,
FieldKind,
ImageField,
Input,
InputField,
LatentsField,
MetadataField,
OutputField,
UIComponent,
UIType,
WithMetadata,
WithWorkflow,
)
from invokeai.app.invocations.primitives import (
BooleanCollectionOutput,
BooleanOutput,
ColorCollectionOutput,
ColorOutput,
ConditioningCollectionOutput,
ConditioningOutput,
DenoiseMaskOutput,
FloatCollectionOutput,
FloatOutput,
ImageCollectionOutput,
ImageOutput,
IntegerCollectionOutput,
IntegerOutput,
LatentsCollectionOutput,
LatentsOutput,
StringCollectionOutput,
StringOutput,
)
from invokeai.app.services.image_records.image_records_common import ImageCategory
from invokeai.app.services.shared.invocation_context import InvocationContext
from invokeai.backend.stable_diffusion.diffusion.conditioning_data import (
BasicConditioningInfo,
ConditioningFieldData,
ExtraConditioningInfo,
SDXLConditioningInfo,
)
__all__ = [
# invokeai.app.invocations.baseinvocation
"BaseInvocation",
"BaseInvocationOutput",
"invocation",
"invocation_output",
# invokeai.app.services.shared.invocation_context
"InvocationContext",
# invokeai.app.invocations.fields
"BoardField",
"ColorField",
"ConditioningField",
"DenoiseMaskField",
"FieldDescriptions",
"FieldKind",
"ImageField",
"Input",
"InputField",
"LatentsField",
"MetadataField",
"OutputField",
"UIComponent",
"UIType",
"WithMetadata",
"WithWorkflow",
# invokeai.app.invocations.primitives
"BooleanCollectionOutput",
"BooleanOutput",
"ColorCollectionOutput",
"ColorOutput",
"ConditioningCollectionOutput",
"ConditioningOutput",
"DenoiseMaskOutput",
"FloatCollectionOutput",
"FloatOutput",
"ImageCollectionOutput",
"ImageOutput",
"IntegerCollectionOutput",
"IntegerOutput",
"LatentsCollectionOutput",
"LatentsOutput",
"StringCollectionOutput",
"StringOutput",
# invokeai.app.services.image_records.image_records_common
"ImageCategory",
# invokeai.backend.stable_diffusion.diffusion.conditioning_data
"BasicConditioningInfo",
"ConditioningFieldData",
"ExtraConditioningInfo",
"SDXLConditioningInfo",
]

View File

@ -170,6 +170,7 @@ version = { attr = "invokeai.version.__version__" }
"invokeai.frontend.web.static*", "invokeai.frontend.web.static*",
"invokeai.configs*", "invokeai.configs*",
"invokeai.app*", "invokeai.app*",
"invokeai.invocation_api*",
] ]
[tool.setuptools.package-data] [tool.setuptools.package-data]