mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
9c89d3452c
feat(nodes): add ResultsServiceABC & SqliteResultsService **Doesn't actually work bc of circular imports. Can't even test it.** - add a base class for ResultsService and SQLite implementation - use `graph_execution_manager` `on_changed` callback to keep `results` table in sync fix(nodes): fix results service bugs chore(ui): regen api fix(ui): fix type guards feat(nodes): add `result_type` to results table, fix types fix(nodes): do not shadow `list` builtin feat(nodes): add results router It doesn't work due to circular imports still fix(nodes): Result class should use outputs classes, not fields feat(ui): crude results router fix(ui): send to canvas in currentimagebuttons not working feat(nodes): add core metadata builder feat(nodes): add design doc feat(nodes): wip latents db stuff feat(nodes): images_db_service and resources router feat(nodes): wip images db & router feat(nodes): update image related names feat(nodes): update urlservice feat(nodes): add high-level images service
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
import os
|
|
from abc import ABC, abstractmethod
|
|
|
|
from invokeai.app.models.image import ImageType
|
|
from invokeai.app.util.thumbnails import get_thumbnail_name
|
|
|
|
|
|
class UrlServiceBase(ABC):
|
|
"""Responsible for building URLs for resources (eg images or tensors)"""
|
|
|
|
@abstractmethod
|
|
def get_image_url(self, image_type: ImageType, image_name: str) -> str:
|
|
"""Gets the URL for an image"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_thumbnail_url(self, image_type: ImageType, image_name: str) -> str:
|
|
"""Gets the URL for an image's thumbnail"""
|
|
pass
|
|
|
|
|
|
class LocalUrlService(UrlServiceBase):
|
|
def __init__(self, base_url: str = "api/v1"):
|
|
self._base_url = base_url
|
|
|
|
def get_image_url(self, image_type: ImageType, image_name: str) -> str:
|
|
image_basename = os.path.basename(image_name)
|
|
return f"{self._base_url}/images/{image_type.value}/{image_basename}"
|
|
|
|
def get_thumbnail_url(self, image_type: ImageType, image_name: str) -> str:
|
|
thumbnail_basename = get_thumbnail_name(os.path.basename(image_name))
|
|
return f"{self._base_url}/images/{image_type.value}/thumbnails/{thumbnail_basename}"
|