1
0
Fork 0

start passing metadata through stages

This commit is contained in:
Sean Sube 2024-01-04 09:01:19 -06:00
parent e3a6635ca2
commit 112d5a8876
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
4 changed files with 30 additions and 14 deletions

View File

@ -205,6 +205,7 @@ class StageResult:
self,
arrays: Optional[List[np.ndarray]] = None,
images: Optional[List[Image.Image]] = None,
metadata: Optional[List[ImageMetadata]] = None,
source: Optional[Any] = None,
) -> None:
if sum([arrays is not None, images is not None, source is not None]) > 1:
@ -215,7 +216,7 @@ class StageResult:
self.arrays = arrays
self.images = images
self.source = source
self.metadata = []
self.metadata = metadata or []
def __len__(self) -> int:
if self.arrays is not None:

View File

@ -117,4 +117,4 @@ class UpscaleRealESRGANStage(BaseStage):
logger.info("final output image size: %s", output.shape)
outputs.append(output)
return StageResult(arrays=outputs)
return StageResult(arrays=outputs, metadata=sources.metadata)

View File

@ -129,7 +129,7 @@ def image_reply(
}
if outputs is not None:
if metadata is None:
if metadata is not None:
logger.error("metadata is required with outputs")
return error_reply("metadata is required with outputs")

View File

@ -70,8 +70,12 @@ export interface CancelledJobResponse extends BaseJobResponse {
reason?: string;
}
export interface UnknownJobResponse extends BaseJobResponse {
status: JobStatus.UNKNOWN;
/**
* Failed image job with error information.
*/
export interface FailedJobResponse extends BaseJobResponse {
status: JobStatus.FAILED;
error: string;
}
/**
@ -86,14 +90,6 @@ export interface RunningJobResponse extends BaseJobResponse {
status: JobStatus.RUNNING;
}
/**
* Failed image job with error information.
*/
export interface FailedJobResponse extends BaseJobResponse {
status: JobStatus.FAILED;
error: string;
}
/**
* Successful txt2img image job with output keys and metadata.
*/
@ -145,9 +141,25 @@ export interface SuccessBlendJobResponse extends BaseJobResponse {
export interface SuccessChainJobResponse extends BaseJobResponse {
status: JobStatus.SUCCESS;
outputs: Array<string>;
metadata: Array<ImageMetadata<BaseImgParams, JobType>>; // TODO: could be all kinds
metadata: Array<
ImageMetadata<Txt2ImgParams, JobType.TXT2IMG>
| ImageMetadata<Img2ImgParams, JobType.IMG2IMG>
| ImageMetadata<InpaintParams, JobType.INPAINT>
| ImageMetadata<BaseImgParams, JobType.UPSCALE>
| ImageMetadata<BaseImgParams, JobType.BLEND>
>;
}
/**
* Unknown job type with no additional information.
*/
export interface UnknownJobResponse extends BaseJobResponse {
status: JobStatus.UNKNOWN;
}
/**
* All successful job types.
*/
export type SuccessJobResponse
= SuccessTxt2ImgJobResponse
| SuccessImg2ImgJobResponse
@ -156,6 +168,9 @@ export type SuccessJobResponse
| SuccessBlendJobResponse
| SuccessChainJobResponse;
/**
* All job types.
*/
export type JobResponse
= CancelledJobResponse
| PendingJobResponse