Skip to content

Commit

Permalink
text-to-image: replace nested dict by height and width properties…
Browse files Browse the repository at this point in the history
… in the input schema (#1158)

Flattening `height` and `width` parameters for `text-to-image`, making
the API simpler for users and making provider-specific transformations
(dict/enum) easier to handle for us.

yes, It's a breaking change but I expect the usage of `target_size` to
be really minimal so far.
  • Loading branch information
hanouticelina authored Feb 4, 2025
1 parent c843fbe commit 48cd514
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
16 changes: 6 additions & 10 deletions packages/tasks/src/tasks/text-to-image/inference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export interface TextToImageParameters {
* the text prompt, but values too high may cause saturation and other artifacts.
*/
guidance_scale?: number;
/**
* The height in pixels of the output image
*/
height?: number;
/**
* One prompt to guide what NOT to include in image generation.
*/
Expand All @@ -44,17 +48,9 @@ export interface TextToImageParameters {
*/
seed?: number;
/**
* The size in pixel of the output image
* The width in pixels of the output image
*/
target_size?: TargetSize;
[property: string]: unknown;
}
/**
* The size in pixel of the output image
*/
export interface TargetSize {
height: number;
width: number;
width?: number;
[property: string]: unknown;
}
/**
Expand Down
19 changes: 7 additions & 12 deletions packages/tasks/src/tasks/text-to-image/spec/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,13 @@
"type": "integer",
"description": "The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference."
},
"target_size": {
"type": "object",
"description": "The size in pixel of the output image",
"properties": {
"width": {
"type": "integer"
},
"height": {
"type": "integer"
}
},
"required": ["width", "height"]
"width": {
"type": "integer",
"description": "The width in pixels of the output image"
},
"height": {
"type": "integer",
"description": "The height in pixels of the output image"
},
"scheduler": {
"type": "string",
Expand Down

0 comments on commit 48cd514

Please sign in to comment.