Skip to content

Commit

Permalink
[Bot] Update inference types (#2712)
Browse files Browse the repository at this point in the history
* Update inference types (automated commit)

* fix quality after merging main

* another fix

* fix tests

* Update inference types (automated commit)

* Update inference types (automated commit)

* fix quality

* Update inference types (automated commit)

* Update inference types (automated commit)

* Update inference types (automated commit)

* fix client

* activate automatic update for table-question-answering

* fix

* Update inference types (automated commit)

* fix quality

* revert generate_kwargs -> generation_parameters renaming

* add docstring back

* add docstring back

---------

Co-authored-by: Wauplin <11801849+Wauplin@users.noreply.github.com>
Co-authored-by: Celina Hanouti <hanouticelina@gmail.com>
  • Loading branch information
3 people authored Jan 27, 2025
1 parent 9410c22 commit 803fa7b
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 27 deletions.
10 changes: 10 additions & 0 deletions docs/source/en/package_reference/inference_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,16 @@ This part of the lib is still under development and will be improved in future r



## text_to_video

[[autodoc]] huggingface_hub.TextToVideoInput

[[autodoc]] huggingface_hub.TextToVideoOutput

[[autodoc]] huggingface_hub.TextToVideoParameters



## token_classification

[[autodoc]] huggingface_hub.TokenClassificationInput
Expand Down
10 changes: 10 additions & 0 deletions docs/source/ko/package_reference/inference_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ rendered properly in your Markdown viewer.



## text_to_video[[huggingface_hub.TextToVideoInput]]

[[autodoc]] huggingface_hub.TextToVideoInput

[[autodoc]] huggingface_hub.TextToVideoOutput

[[autodoc]] huggingface_hub.TextToVideoParameters



## token_classification[[huggingface_hub.TokenClassificationInput]]

[[autodoc]] huggingface_hub.TokenClassificationInput
Expand Down
9 changes: 9 additions & 0 deletions src/huggingface_hub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@
"TextToSpeechInput",
"TextToSpeechOutput",
"TextToSpeechParameters",
"TextToVideoInput",
"TextToVideoOutput",
"TextToVideoParameters",
"TokenClassificationAggregationStrategy",
"TokenClassificationInput",
"TokenClassificationOutputElement",
Expand Down Expand Up @@ -705,6 +708,9 @@
"TextToSpeechInput",
"TextToSpeechOutput",
"TextToSpeechParameters",
"TextToVideoInput",
"TextToVideoOutput",
"TextToVideoParameters",
"TokenClassificationAggregationStrategy",
"TokenClassificationInput",
"TokenClassificationOutputElement",
Expand Down Expand Up @@ -1334,6 +1340,9 @@ def __dir__():
TextToSpeechInput, # noqa: F401
TextToSpeechOutput, # noqa: F401
TextToSpeechParameters, # noqa: F401
TextToVideoInput, # noqa: F401
TextToVideoOutput, # noqa: F401
TextToVideoParameters, # noqa: F401
TokenClassificationAggregationStrategy, # noqa: F401
TokenClassificationInput, # noqa: F401
TokenClassificationOutputElement, # noqa: F401
Expand Down
12 changes: 6 additions & 6 deletions src/huggingface_hub/inference/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ def image_to_image(
image: ContentT,
prompt: Optional[str] = None,
*,
negative_prompt: Optional[List[str]] = None,
negative_prompt: Optional[str] = None,
num_inference_steps: Optional[int] = None,
guidance_scale: Optional[float] = None,
model: Optional[str] = None,
Expand All @@ -1301,8 +1301,8 @@ def image_to_image(
The input image for translation. It can be raw bytes, an image file, or a URL to an online image.
prompt (`str`, *optional*):
The text prompt to guide the image generation.
negative_prompt (`List[str]`, *optional*):
One or several prompt to guide what NOT to include in image generation.
negative_prompt (`str`, *optional*):
One prompt to guide what NOT to include in image generation.
num_inference_steps (`int`, *optional*):
For diffusion models. The number of denoising steps. More denoising steps usually lead to a higher
quality image at the expense of slower inference.
Expand Down Expand Up @@ -2377,7 +2377,7 @@ def text_to_image(
self,
prompt: str,
*,
negative_prompt: Optional[List[str]] = None,
negative_prompt: Optional[str] = None,
height: Optional[float] = None,
width: Optional[float] = None,
num_inference_steps: Optional[int] = None,
Expand All @@ -2400,8 +2400,8 @@ def text_to_image(
Args:
prompt (`str`):
The prompt to generate an image from.
negative_prompt (`List[str`, *optional*):
One or several prompt to guide what NOT to include in image generation.
negative_prompt (`str`, *optional*):
One prompt to guide what NOT to include in image generation.
height (`float`, *optional*):
The height in pixels of the image to generate.
width (`float`, *optional*):
Expand Down
12 changes: 6 additions & 6 deletions src/huggingface_hub/inference/_generated/_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ async def image_to_image(
image: ContentT,
prompt: Optional[str] = None,
*,
negative_prompt: Optional[List[str]] = None,
negative_prompt: Optional[str] = None,
num_inference_steps: Optional[int] = None,
guidance_scale: Optional[float] = None,
model: Optional[str] = None,
Expand All @@ -1349,8 +1349,8 @@ async def image_to_image(
The input image for translation. It can be raw bytes, an image file, or a URL to an online image.
prompt (`str`, *optional*):
The text prompt to guide the image generation.
negative_prompt (`List[str]`, *optional*):
One or several prompt to guide what NOT to include in image generation.
negative_prompt (`str`, *optional*):
One prompt to guide what NOT to include in image generation.
num_inference_steps (`int`, *optional*):
For diffusion models. The number of denoising steps. More denoising steps usually lead to a higher
quality image at the expense of slower inference.
Expand Down Expand Up @@ -2436,7 +2436,7 @@ async def text_to_image(
self,
prompt: str,
*,
negative_prompt: Optional[List[str]] = None,
negative_prompt: Optional[str] = None,
height: Optional[float] = None,
width: Optional[float] = None,
num_inference_steps: Optional[int] = None,
Expand All @@ -2459,8 +2459,8 @@ async def text_to_image(
Args:
prompt (`str`):
The prompt to generate an image from.
negative_prompt (`List[str`, *optional*):
One or several prompt to guide what NOT to include in image generation.
negative_prompt (`str`, *optional*):
One prompt to guide what NOT to include in image generation.
height (`float`, *optional*):
The height in pixels of the image to generate.
width (`float`, *optional*):
Expand Down
1 change: 1 addition & 0 deletions src/huggingface_hub/inference/_generated/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
TextToSpeechOutput,
TextToSpeechParameters,
)
from .text_to_video import TextToVideoInput, TextToVideoOutput, TextToVideoParameters
from .token_classification import (
TokenClassificationAggregationStrategy,
TokenClassificationInput,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
# - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
from dataclasses import dataclass
from typing import Any, List, Optional
from typing import Any, Optional

from .base import BaseInferenceType

Expand All @@ -25,8 +25,8 @@ class ImageToImageParameters(BaseInferenceType):
"""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.
"""
negative_prompt: Optional[List[str]] = None
"""One or several prompt to guide what NOT to include in image generation."""
negative_prompt: Optional[str] = None
"""One prompt to guide what NOT to include in image generation."""
num_inference_steps: Optional[int] = None
"""For diffusion models. The number of denoising steps. More denoising steps usually lead to
a higher quality image at the expense of slower inference.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,5 @@ class TextToAudioOutput(BaseInferenceType):

audio: Any
"""The generated audio waveform."""
sampling_rate: Any
text_to_audio_output_sampling_rate: Optional[float] = None
sampling_rate: float
"""The sampling rate of the generated audio waveform."""
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
# - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
from dataclasses import dataclass
from typing import Any, List, Optional
from typing import Any, Optional

from .base import BaseInferenceType

Expand All @@ -25,8 +25,8 @@ class TextToImageParameters(BaseInferenceType):
"""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: Optional[List[str]] = None
"""One or several prompt to guide what NOT to include in image generation."""
negative_prompt: Optional[str] = None
"""One prompt to guide what NOT to include in image generation."""
num_inference_steps: Optional[int] = None
"""The number of denoising steps. More denoising steps usually lead to a higher quality
image at the expense of slower inference.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,9 @@ class TextToSpeechInput(BaseInferenceType):

@dataclass
class TextToSpeechOutput(BaseInferenceType):
"""Outputs for Text to Speech inference
Outputs of inference for the Text To Audio task
"""
"""Outputs of inference for the Text To Speech task"""

audio: Any
"""The generated audio waveform."""
sampling_rate: Any
text_to_speech_output_sampling_rate: Optional[float] = None
"""The generated audio"""
sampling_rate: Optional[float] = None
"""The sampling rate of the generated audio waveform."""
47 changes: 47 additions & 0 deletions src/huggingface_hub/inference/_generated/types/text_to_video.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Inference code generated from the JSON schema spec in @huggingface/tasks.
#
# See:
# - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
# - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
from dataclasses import dataclass
from typing import Any, List, Optional

from .base import BaseInferenceType


@dataclass
class TextToVideoParameters(BaseInferenceType):
"""Additional inference parameters for Text To Video"""

guidance_scale: Optional[float] = None
"""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: Optional[List[str]] = None
"""One or several prompt to guide what NOT to include in image generation."""
num_frames: Optional[float] = None
"""The num_frames parameter determines how many video frames are generated."""
num_inference_steps: Optional[int] = None
"""The number of denoising steps. More denoising steps usually lead to a higher quality
image at the expense of slower inference.
"""
seed: Optional[int] = None
"""Seed for the random number generator."""


@dataclass
class TextToVideoInput(BaseInferenceType):
"""Inputs for Text To Video inference"""

inputs: str
"""The input text data (sometimes called "prompt")"""
parameters: Optional[TextToVideoParameters] = None
"""Additional inference parameters for Text To Video"""


@dataclass
class TextToVideoOutput(BaseInferenceType):
"""Outputs of inference for the Text To Video task"""

video: Any
"""The generated video returned as raw bytes in the payload."""
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class VisualQuestionAnsweringInputData(BaseInferenceType):

image: Any
"""The image."""
question: Any
question: str
"""The question to answer based on the image."""


Expand Down

0 comments on commit 803fa7b

Please sign in to comment.