Skip to content

Commit

Permalink
Add seed in text to image specs (#888)
Browse files Browse the repository at this point in the history
Following @apolinario's PR
huggingface/api-inference-community#450. This PR
adds a "seed" input parameter in the `text-to-image` specs.

---------

Co-authored-by: Pedro Cuenca <pedro@huggingface.co>
  • Loading branch information
Wauplin and pcuenca authored Sep 2, 2024
1 parent 82d8224 commit 1701fac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
14 changes: 9 additions & 5 deletions packages/tasks/src/tasks/text-to-image/inference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,27 @@ export interface TextToImageInput {
*/
export interface TextToImageParameters {
/**
* For diffusion models. A higher guidance scale value encourages the model to generate
* images closely linked to the text prompt at the expense of lower image quality.
* A higher guidance scale value encourages the model to generate images closely linked to
* the text prompt, but values too high may cause saturation and other artifacts.
*/
guidance_scale?: number;
/**
* One or several prompt to guide what NOT to include in image generation.
*/
negative_prompt?: string[];
/**
* For diffusion models. The number of denoising steps. More denoising steps usually lead to
* a higher quality image at the expense of slower inference.
* The number of denoising steps. More denoising steps usually lead to a higher quality
* image at the expense of slower inference.
*/
num_inference_steps?: number;
/**
* For diffusion models. Override the scheduler with a compatible one
* Override the scheduler with a compatible one.
*/
scheduler?: string;
/**
* Seed for the random number generator.
*/
seed?: number;
/**
* The size in pixel of the output image
*/
Expand Down
10 changes: 7 additions & 3 deletions packages/tasks/src/tasks/text-to-image/spec/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"properties": {
"guidance_scale": {
"type": "number",
"description": "For diffusion models. A higher guidance scale value encourages the model to generate images closely linked to the text prompt at the expense of lower image quality."
"description": "A higher guidance scale value encourages the model to generate images closely linked to the text prompt, but values too high may cause saturation and other artifacts."
},
"negative_prompt": {
"type": "array",
Expand All @@ -33,7 +33,7 @@
},
"num_inference_steps": {
"type": "integer",
"description": "For diffusion models. The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference."
"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",
Expand All @@ -50,7 +50,11 @@
},
"scheduler": {
"type": "string",
"description": "For diffusion models. Override the scheduler with a compatible one"
"description": "Override the scheduler with a compatible one."
},
"seed": {
"type": "integer",
"description": "Seed for the random number generator."
}
}
}
Expand Down

0 comments on commit 1701fac

Please sign in to comment.