start passing metadata through stages
This commit is contained in:
parent
e3a6635ca2
commit
112d5a8876
|
@ -205,6 +205,7 @@ class StageResult:
|
||||||
self,
|
self,
|
||||||
arrays: Optional[List[np.ndarray]] = None,
|
arrays: Optional[List[np.ndarray]] = None,
|
||||||
images: Optional[List[Image.Image]] = None,
|
images: Optional[List[Image.Image]] = None,
|
||||||
|
metadata: Optional[List[ImageMetadata]] = None,
|
||||||
source: Optional[Any] = None,
|
source: Optional[Any] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
if sum([arrays is not None, images is not None, source is not None]) > 1:
|
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.arrays = arrays
|
||||||
self.images = images
|
self.images = images
|
||||||
self.source = source
|
self.source = source
|
||||||
self.metadata = []
|
self.metadata = metadata or []
|
||||||
|
|
||||||
def __len__(self) -> int:
|
def __len__(self) -> int:
|
||||||
if self.arrays is not None:
|
if self.arrays is not None:
|
||||||
|
|
|
@ -117,4 +117,4 @@ class UpscaleRealESRGANStage(BaseStage):
|
||||||
logger.info("final output image size: %s", output.shape)
|
logger.info("final output image size: %s", output.shape)
|
||||||
outputs.append(output)
|
outputs.append(output)
|
||||||
|
|
||||||
return StageResult(arrays=outputs)
|
return StageResult(arrays=outputs, metadata=sources.metadata)
|
||||||
|
|
|
@ -129,7 +129,7 @@ def image_reply(
|
||||||
}
|
}
|
||||||
|
|
||||||
if outputs is not None:
|
if outputs is not None:
|
||||||
if metadata is None:
|
if metadata is not None:
|
||||||
logger.error("metadata is required with outputs")
|
logger.error("metadata is required with outputs")
|
||||||
return error_reply("metadata is required with outputs")
|
return error_reply("metadata is required with outputs")
|
||||||
|
|
||||||
|
|
|
@ -70,8 +70,12 @@ export interface CancelledJobResponse extends BaseJobResponse {
|
||||||
reason?: string;
|
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;
|
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.
|
* Successful txt2img image job with output keys and metadata.
|
||||||
*/
|
*/
|
||||||
|
@ -145,9 +141,25 @@ export interface SuccessBlendJobResponse extends BaseJobResponse {
|
||||||
export interface SuccessChainJobResponse extends BaseJobResponse {
|
export interface SuccessChainJobResponse extends BaseJobResponse {
|
||||||
status: JobStatus.SUCCESS;
|
status: JobStatus.SUCCESS;
|
||||||
outputs: Array<string>;
|
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
|
export type SuccessJobResponse
|
||||||
= SuccessTxt2ImgJobResponse
|
= SuccessTxt2ImgJobResponse
|
||||||
| SuccessImg2ImgJobResponse
|
| SuccessImg2ImgJobResponse
|
||||||
|
@ -156,6 +168,9 @@ export type SuccessJobResponse
|
||||||
| SuccessBlendJobResponse
|
| SuccessBlendJobResponse
|
||||||
| SuccessChainJobResponse;
|
| SuccessChainJobResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All job types.
|
||||||
|
*/
|
||||||
export type JobResponse
|
export type JobResponse
|
||||||
= CancelledJobResponse
|
= CancelledJobResponse
|
||||||
| PendingJobResponse
|
| PendingJobResponse
|
||||||
|
|
Loading…
Reference in New Issue