Skip to content

Commit 48cd514

Browse files
text-to-image: replace nested dict by height and width properties in the input schema (huggingface#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.
1 parent c843fbe commit 48cd514

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

packages/tasks/src/tasks/text-to-image/inference.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export interface TextToImageParameters {
2626
* the text prompt, but values too high may cause saturation and other artifacts.
2727
*/
2828
guidance_scale?: number;
29+
/**
30+
* The height in pixels of the output image
31+
*/
32+
height?: number;
2933
/**
3034
* One prompt to guide what NOT to include in image generation.
3135
*/
@@ -44,17 +48,9 @@ export interface TextToImageParameters {
4448
*/
4549
seed?: number;
4650
/**
47-
* The size in pixel of the output image
51+
* The width in pixels of the output image
4852
*/
49-
target_size?: TargetSize;
50-
[property: string]: unknown;
51-
}
52-
/**
53-
* The size in pixel of the output image
54-
*/
55-
export interface TargetSize {
56-
height: number;
57-
width: number;
53+
width?: number;
5854
[property: string]: unknown;
5955
}
6056
/**

packages/tasks/src/tasks/text-to-image/spec/input.json

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,13 @@
3131
"type": "integer",
3232
"description": "The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference."
3333
},
34-
"target_size": {
35-
"type": "object",
36-
"description": "The size in pixel of the output image",
37-
"properties": {
38-
"width": {
39-
"type": "integer"
40-
},
41-
"height": {
42-
"type": "integer"
43-
}
44-
},
45-
"required": ["width", "height"]
34+
"width": {
35+
"type": "integer",
36+
"description": "The width in pixels of the output image"
37+
},
38+
"height": {
39+
"type": "integer",
40+
"description": "The height in pixels of the output image"
4641
},
4742
"scheduler": {
4843
"type": "string",

0 commit comments

Comments
 (0)