Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
6344cad
feat(nodes): add high-level images service
psychedelicious May 17, 2023
63ee063
feat(nodes): image records router
psychedelicious May 21, 2023
e72fe00
fix(nodes): use `save` instead of `set`
psychedelicious May 21, 2023
23ed5c2
feat(nodes): wip image storage implementation
psychedelicious May 21, 2023
9c0e5d2
feat(logger): fix logger type issues
psychedelicious May 21, 2023
d68626f
feat(nodes): add logger to images service
psychedelicious May 21, 2023
20c3068
feat(nodes): fix types for InvocationServices
psychedelicious May 21, 2023
9d7ea1f
feat(nodes): it works
psychedelicious May 21, 2023
395e496
fix(nodes): remove bad import
psychedelicious May 21, 2023
bd08a9e
feat(nodes): streamline urlservice
psychedelicious May 21, 2023
c8e1d40
hack(nodes): hack to get image urls in the invocation complete event
psychedelicious May 21, 2023
13222f9
feat(nodes): organise/tidy
psychedelicious May 21, 2023
8bafc0b
fix(nodes): add base images router
psychedelicious May 21, 2023
9d68ac6
fix(nodes): restore metadata traverser
psychedelicious May 21, 2023
12a43fe
build(ui): do not export schemas on api client generation
psychedelicious May 22, 2023
52fe8b9
chore(ui): regen api client
psychedelicious May 22, 2023
195bfe6
feat(nodes): revert invocation_complete url hack
psychedelicious May 22, 2023
d1e52d0
feat(nodes): consolidate image routers
psychedelicious May 22, 2023
e9ede6b
chore(ui): regen api client
psychedelicious May 22, 2023
9652696
feat(nodes): add metadata handling
psychedelicious May 22, 2023
13951e4
chore(ui): regen api client
psychedelicious May 22, 2023
1a1403d
feat(ui): add POC image record fetching
psychedelicious May 22, 2023
0c5ab95
fix(nodes): fix image url
psychedelicious May 22, 2023
e74798e
feat(nodes): finalize image routes
psychedelicious May 22, 2023
b3a33df
fix(nodes): tidy images service
psychedelicious May 22, 2023
23c2a3a
chore(ui): regen api client
psychedelicious May 22, 2023
0de4f2e
feat(ui): wip use new images service
psychedelicious May 22, 2023
6b1193a
fix(ui): fix image nodes losing image
psychedelicious May 22, 2023
6689241
feat(ui): wip update UI for migration
psychedelicious May 22, 2023
ecbbcfd
feat(nodes): improve metadata service comments
psychedelicious May 23, 2023
69932af
feat(nodes): address feedback
psychedelicious May 23, 2023
0849ac9
chore(ui): regen api client
psychedelicious May 23, 2023
c640bb7
fix(nodes): fix bugs with serving images
psychedelicious May 23, 2023
46bafed
fix(ui): fix gallery bugs
psychedelicious May 23, 2023
7033dd8
fix(ui): fix image deletion
psychedelicious May 23, 2023
5aacb36
fix(ui): fix uploads & other bugs
psychedelicious May 23, 2023
0aeea82
fix(nodes): add RangeInvocation validator
psychedelicious May 24, 2023
59f26d0
feat(nodes): add seed validator
psychedelicious May 24, 2023
ff12afc
feat(nodes): add RangeOfSizeInvocation
psychedelicious May 24, 2023
80887b6
fix(nodes): fix RangeOfSizeInvocation off-by-one error
psychedelicious May 24, 2023
4bde5cb
feat(nodes): move fully* to new images service
psychedelicious May 24, 2023
2de9e66
feat(ui): migrate linear workflows to latents
psychedelicious May 24, 2023
21d7b20
feat(nodes): add mask image category
psychedelicious May 24, 2023
fca95ef
feat(nodes): add image mul, channel, convert nodes
psychedelicious May 24, 2023
91efe69
feat(nodes): comment out seamless
psychedelicious May 24, 2023
00a0f1d
feat(nodes): wip inpainting nodes prep
psychedelicious May 24, 2023
1261113
fix(ui): fix uploads tab in gallery
psychedelicious May 24, 2023
7d915c3
feat(ui): misc tidy
psychedelicious May 24, 2023
4dd16b9
feat(ui): restore canvas functionality
psychedelicious May 24, 2023
b9a2e42
feat(nodes): restore canvas functionality (non-latents)
psychedelicious May 24, 2023
f5539b4
fix(nodes): rebase fixes
psychedelicious May 24, 2023
8ee73e8
build(nodes): remove outdated metadata test
psychedelicious May 24, 2023
857acdf
build(nodes): remove references to metadata service in tests
psychedelicious May 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 36 additions & 17 deletions invokeai/app/api/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654)

from logging import Logger
import os

import invokeai.backend.util.logging as logger
from typing import types
from invokeai.app.services.image_record_storage import SqliteImageRecordStorage
from invokeai.app.services.images import ImageService
from invokeai.app.services.metadata import CoreMetadataService
from invokeai.app.services.urls import LocalUrlService
from invokeai.backend.util.logging import InvokeAILogger

from ..services.default_graphs import create_system_graphs
from ..services.latent_storage import DiskLatentsStorage, ForwardCacheLatentsStorage
from ..services.model_manager_initializer import get_model_manager
from ..services.restoration_services import RestorationServices
from ..services.graph import GraphExecutionState, LibraryGraph
from ..services.image_storage import DiskImageStorage
from ..services.image_file_storage import DiskImageFileStorage
from ..services.invocation_queue import MemoryInvocationQueue
from ..services.invocation_services import InvocationServices
from ..services.invoker import Invoker
from ..services.processor import DefaultInvocationProcessor
from ..services.sqlite import SqliteItemStorage
from ..services.metadata import PngMetadataService
from .events import FastAPIEventService


Expand All @@ -36,12 +38,16 @@ def check_internet() -> bool:
return False


logger = InvokeAILogger.getLogger()


class ApiDependencies:
"""Contains and initializes all dependencies for the API"""

invoker: Invoker = None

def initialize(config, event_handler_id: int, logger: types.ModuleType=logger):
@staticmethod
def initialize(config, event_handler_id: int, logger: Logger = logger):
logger.info(f"Internet connectivity is {config.internet_available}")

events = FastAPIEventService(event_handler_id)
Expand All @@ -50,30 +56,43 @@ def initialize(config, event_handler_id: int, logger: types.ModuleType=logger):
os.path.join(os.path.dirname(__file__), "../../../../outputs")
)

latents = ForwardCacheLatentsStorage(DiskLatentsStorage(f'{output_folder}/latents'))
# TODO: build a file/path manager?
db_location = os.path.join(output_folder, "invokeai.db")

metadata = PngMetadataService()
graph_execution_manager = SqliteItemStorage[GraphExecutionState](
filename=db_location, table_name="graph_executions"
)

images = DiskImageStorage(f'{output_folder}/images', metadata_service=metadata)
urls = LocalUrlService()
metadata = CoreMetadataService()
image_record_storage = SqliteImageRecordStorage(db_location)
image_file_storage = DiskImageFileStorage(f"{output_folder}/images")

# TODO: build a file/path manager?
db_location = os.path.join(output_folder, "invokeai.db")
latents = ForwardCacheLatentsStorage(
DiskLatentsStorage(f"{output_folder}/latents")
)

images = ImageService(
image_record_storage=image_record_storage,
image_file_storage=image_file_storage,
metadata=metadata,
url=urls,
logger=logger,
graph_execution_manager=graph_execution_manager,
)

services = InvocationServices(
model_manager=get_model_manager(config,logger),
model_manager=get_model_manager(config, logger),
events=events,
latents=latents,
images=images,
metadata=metadata,
queue=MemoryInvocationQueue(),
graph_library=SqliteItemStorage[LibraryGraph](
filename=db_location, table_name="graphs"
),
graph_execution_manager=SqliteItemStorage[GraphExecutionState](
filename=db_location, table_name="graph_executions"
),
graph_execution_manager=graph_execution_manager,
processor=DefaultInvocationProcessor(),
restoration=RestorationServices(config,logger),
restoration=RestorationServices(config, logger),
configuration=config,
logger=logger,
)
Expand Down
7 changes: 3 additions & 4 deletions invokeai/app/api/models/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from pydantic import BaseModel, Field

from invokeai.app.models.image import ImageType
from invokeai.app.services.metadata import InvokeAIMetadata


class ImageResponseMetadata(BaseModel):
Expand All @@ -11,9 +10,9 @@ class ImageResponseMetadata(BaseModel):
created: int = Field(description="The creation timestamp of the image")
width: int = Field(description="The width of the image in pixels")
height: int = Field(description="The height of the image in pixels")
invokeai: Optional[InvokeAIMetadata] = Field(
description="The image's InvokeAI-specific metadata"
)
# invokeai: Optional[InvokeAIMetadata] = Field(
# description="The image's InvokeAI-specific metadata"
# )


class ImageResponse(BaseModel):
Expand Down
Loading