mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
d2c8a53c55
- `ImageType` is now restricted to `results` and `uploads`. - Add a reserved `meta` field to nodes to hold the `is_intermediate` boolean. We can extend it in the future to support other node `meta`. - Add a `is_intermediate` column to the `images` table to hold this. (When `latents`, `conditioning` etc are added to the DB, they will also have this column.) - All nodes default to `*not* intermediate`. Nodes must explicitly be marked `intermediate` for their outputs to be `intermediate`. - When building a graph, you can set `node.meta.is_intermediate=True` and it will be handled as an intermediate. - Add a new `update()` method to the `ImageService`, and a route to call it. Updates have a strict model, currently only `session_id` and `image_category` may be updated. - Add a new `update()` method to the `ImageRecordStorageService` to update the image record using the model.
64 lines
1.7 KiB
Python
64 lines
1.7 KiB
Python
from enum import Enum
|
|
from typing import Optional, Tuple
|
|
from pydantic import BaseModel, Field
|
|
|
|
from invokeai.app.util.metaenum import MetaEnum
|
|
|
|
|
|
class ImageType(str, Enum, metaclass=MetaEnum):
|
|
"""The type of an image."""
|
|
|
|
RESULT = "results"
|
|
UPLOAD = "uploads"
|
|
|
|
|
|
class InvalidImageTypeException(ValueError):
|
|
"""Raised when a provided value is not a valid ImageType.
|
|
|
|
Subclasses `ValueError`.
|
|
"""
|
|
|
|
def __init__(self, message="Invalid image type."):
|
|
super().__init__(message)
|
|
|
|
|
|
class ImageCategory(str, Enum, metaclass=MetaEnum):
|
|
"""The category of an image. Use ImageCategory.OTHER for non-default categories."""
|
|
|
|
GENERAL = "general"
|
|
CONTROL = "control"
|
|
MASK = "mask"
|
|
OTHER = "other"
|
|
|
|
|
|
class InvalidImageCategoryException(ValueError):
|
|
"""Raised when a provided value is not a valid ImageCategory.
|
|
|
|
Subclasses `ValueError`.
|
|
"""
|
|
|
|
def __init__(self, message="Invalid image category."):
|
|
super().__init__(message)
|
|
|
|
|
|
class ImageField(BaseModel):
|
|
"""An image field used for passing image objects between invocations"""
|
|
|
|
image_type: ImageType = Field(
|
|
default=ImageType.RESULT, description="The type of the image"
|
|
)
|
|
image_name: Optional[str] = Field(default=None, description="The name of the image")
|
|
|
|
class Config:
|
|
schema_extra = {"required": ["image_type", "image_name"]}
|
|
|
|
|
|
class ColorField(BaseModel):
|
|
r: int = Field(ge=0, le=255, description="The red component")
|
|
g: int = Field(ge=0, le=255, description="The green component")
|
|
b: int = Field(ge=0, le=255, description="The blue component")
|
|
a: int = Field(ge=0, le=255, description="The alpha component")
|
|
|
|
def tuple(self) -> Tuple[int, int, int, int]:
|
|
return (self.r, self.g, self.b, self.a)
|