ImageGenerator

ImageGenerator(*args, **kwargs)

This class defines an interface for image generators.
Concrete implementations of this protocol must provide a generate_image method that takes a string prompt as input and returns a PIL Image object.
NOTE: Current implementation does not allow you to edit a previously existing image.

Parameters:
NameDescription
*args
**kwargs

Instance Methods

cache_key

cache_key(self, prompt: str) -> str

Generates a unique cache key for the given prompt.
This key can be used to store and retrieve generated images based on the prompt.

Parameters:
NameDescription
promptA string describing the desired image.

Type: str
Returns:
TypeDescription
strA unique string that can be used as a cache key.

generate_image

generate_image(self, prompt: str) -> Image

Generates an image based on the provided prompt.

Parameters:
NameDescription
promptA string describing the desired image.

Type: str
Returns:
TypeDescription
ImageA PIL Image object representing the generated image.