Spaces:
Runtime error
Runtime error
File size: 1,494 Bytes
5fbd25d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
"""
Task and job related models
"""
from enum import Enum
from pydantic import (
BaseModel,
Field
)
class TaskType(str, Enum):
"""
Task type object
"""
text_2_img = 'Text to Image'
img_uov = 'Image Upscale or Variation'
img_inpaint_outpaint = 'Image Inpaint or Outpaint'
img_prompt = 'Image Prompt'
img_enhance = 'Image Enhancement'
not_found = 'Not Found'
class GenerationFinishReason(str, Enum):
"""
Generation finish reason
"""
success = 'SUCCESS'
queue_is_full = 'QUEUE_IS_FULL'
user_cancel = 'USER_CANCEL'
error = 'ERROR'
class ImageGenerationResult:
"""
Image generation result
"""
def __init__(self, im: str | None, seed: str, finish_reason: GenerationFinishReason):
self.im = im
self.seed = seed
self.finish_reason = finish_reason
class AsyncJobStage(str, Enum):
"""
Async job stage
"""
waiting = 'WAITING'
running = 'RUNNING'
success = 'SUCCESS'
error = 'ERROR'
class GeneratedImageResult(BaseModel):
"""
Generated images result
"""
base64: str | None = Field(
description="Image encoded in base64, or null if finishReason is not 'SUCCESS', only return when request require base64")
url: str | None = Field(description="Image file static serve url, or null if finishReason is not 'SUCCESS'")
seed: str = Field(description="The seed associated with this image")
finish_reason: GenerationFinishReason
|