mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
33a0af4637
Currenly only used to make names for images, but when latents, conditioning, etc are managed in DB, will do the same for them. Intended to eventually support custom naming schemes.
31 lines
756 B
Python
31 lines
756 B
Python
from abc import ABC, abstractmethod
|
|
from enum import Enum, EnumMeta
|
|
import uuid
|
|
|
|
|
|
class ResourceType(str, Enum, metaclass=EnumMeta):
|
|
"""Enum for resource types."""
|
|
|
|
IMAGE = "image"
|
|
LATENT = "latent"
|
|
|
|
|
|
class NameServiceBase(ABC):
|
|
"""Low-level service responsible for naming resources (images, latents, etc)."""
|
|
|
|
# TODO: Add customizable naming schemes
|
|
@abstractmethod
|
|
def create_image_name(self) -> str:
|
|
"""Creates a name for an image."""
|
|
pass
|
|
|
|
|
|
class SimpleNameService(NameServiceBase):
|
|
"""Creates image names from UUIDs."""
|
|
|
|
# TODO: Add customizable naming schemes
|
|
def create_image_name(self) -> str:
|
|
uuid_str = str(uuid.uuid4())
|
|
filename = f"{uuid_str}.png"
|
|
return filename
|