mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(nodes): image records router
This commit is contained in:
parent
9c89d3452c
commit
33d199c007
@ -11,7 +11,7 @@ from invokeai.app.services.item_storage import PaginatedResults
|
||||
|
||||
from ..dependencies import ApiDependencies
|
||||
|
||||
image_records_router = APIRouter(prefix="/v1/records/images", tags=["records"])
|
||||
image_records_router = APIRouter(prefix="/v1/images", tags=["images", "records"])
|
||||
|
||||
|
||||
@image_records_router.get("/{image_type}/{image_name}", operation_id="get_image_record")
|
||||
@ -57,7 +57,7 @@ async def list_image_records(
|
||||
|
||||
@image_records_router.delete("/{image_type}/{image_name}", operation_id="delete_image")
|
||||
async def delete_image_record(
|
||||
image_type: ImageType = Query(description="The type of image records to get"),
|
||||
image_type: ImageType = Query(description="The type of image to delete"),
|
||||
image_name: str = Path(description="The name of the image to delete"),
|
||||
) -> None:
|
||||
"""Deletes an image record"""
|
@ -19,7 +19,7 @@ from invokeai.app.services.item_storage import PaginatedResults
|
||||
|
||||
from ..dependencies import ApiDependencies
|
||||
|
||||
images_router = APIRouter(prefix="/v1/images", tags=["images"])
|
||||
images_router = APIRouter(prefix="/v1/files/images", tags=["images", "files"])
|
||||
|
||||
|
||||
# @images_router.get("/{image_type}/{image_name}", operation_id="get_image")
|
||||
@ -38,15 +38,16 @@ images_router = APIRouter(prefix="/v1/images", tags=["images"])
|
||||
# else:
|
||||
# raise HTTPException(status_code=404)
|
||||
|
||||
@images_router.get("/{image_type}/{image_id}", operation_id="get_image")
|
||||
|
||||
@images_router.get("/{image_type}/{image_name}", operation_id="get_image")
|
||||
async def get_image(
|
||||
image_type: ImageType = Path(description="The type of the image to get"),
|
||||
image_id: str = Path(description="The id of the image to get"),
|
||||
image_name: str = Path(description="The id of the image to get"),
|
||||
) -> FileResponse:
|
||||
"""Gets an image"""
|
||||
|
||||
path = ApiDependencies.invoker.services.images.get_path(
|
||||
image_type=image_type, image_id=image_id
|
||||
image_type=image_type, image_name=image_name
|
||||
)
|
||||
|
||||
if ApiDependencies.invoker.services.images.validate_path(path):
|
||||
@ -77,7 +78,7 @@ async def get_thumbnail(
|
||||
"""Gets a thumbnail"""
|
||||
|
||||
path = ApiDependencies.invoker.services.images.get_path(
|
||||
image_type=image_type, image_id=thumbnail_id, is_thumbnail=True
|
||||
image_type=image_type, image_name=thumbnail_id, is_thumbnail=True
|
||||
)
|
||||
|
||||
if ApiDependencies.invoker.services.images.validate_path(path):
|
||||
|
@ -15,7 +15,7 @@ from fastapi_events.middleware import EventHandlerASGIMiddleware
|
||||
from pydantic.schema import schema
|
||||
|
||||
from .api.dependencies import ApiDependencies
|
||||
from .api.routers import image_resources, images, sessions, models
|
||||
from .api.routers import image_records, images, sessions, models
|
||||
from .api.sockets import SocketIO
|
||||
from .invocations.baseinvocation import BaseInvocation
|
||||
from .services.config import InvokeAIAppConfig
|
||||
@ -75,7 +75,7 @@ app.include_router(images.images_router, prefix="/api")
|
||||
|
||||
app.include_router(models.models_router, prefix="/api")
|
||||
|
||||
app.include_router(image_resources.image_resources_router, prefix="/api")
|
||||
app.include_router(image_records.image_records_router, prefix="/api")
|
||||
|
||||
|
||||
# Build a custom OpenAPI to include all outputs
|
||||
|
@ -74,6 +74,20 @@ class ImageStorageBase(ABC):
|
||||
) -> str:
|
||||
"""Gets the external URI to an image or its thumbnail."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_image_location(
|
||||
self, image_type: ImageType, image_name: str
|
||||
) -> str:
|
||||
"""Gets the location of an image."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_thumbnail_location(
|
||||
self, image_type: ImageType, image_name: str
|
||||
) -> str:
|
||||
"""Gets the location of an image's thumbnail."""
|
||||
pass
|
||||
|
||||
# TODO: make this a bit more flexible for e.g. cloud storage
|
||||
@abstractmethod
|
||||
|
Loading…
Reference in New Issue
Block a user