Merge pull request #3866 from kinaryml:fix-tasks-api-python-311-errors

PiperOrigin-RevId: 489346167
This commit is contained in:
Copybara-Service 2022-11-17 17:20:23 -08:00
commit cd056e114a
7 changed files with 18 additions and 8 deletions

View File

@ -70,7 +70,8 @@ class AudioClassifierOptions:
"""
base_options: _BaseOptions
running_mode: _RunningMode = _RunningMode.AUDIO_CLIPS
classifier_options: _ClassifierOptions = _ClassifierOptions()
classifier_options: Optional[_ClassifierOptions] = dataclasses.field(
default_factory=_ClassifierOptions)
result_callback: Optional[Callable[[AudioClassifierResult, int], None]] = None
@doc_controls.do_not_generate_docs

View File

@ -71,7 +71,8 @@ class AudioEmbedderOptions:
"""
base_options: _BaseOptions
running_mode: _RunningMode = _RunningMode.AUDIO_CLIPS
embedder_options: _EmbedderOptions = _EmbedderOptions()
embedder_options: Optional[_EmbedderOptions] = dataclasses.field(
default_factory=_EmbedderOptions)
result_callback: Optional[Callable[[AudioEmbedderResult, int], None]] = None
@doc_controls.do_not_generate_docs

View File

@ -14,6 +14,7 @@
"""MediaPipe text classifier task."""
import dataclasses
from typing import Optional
from mediapipe.python import packet_creator
from mediapipe.python import packet_getter
@ -48,7 +49,8 @@ class TextClassifierOptions:
classifier_options: Options for the text classification task.
"""
base_options: _BaseOptions
classifier_options: _ClassifierOptions = _ClassifierOptions()
classifier_options: Optional[_ClassifierOptions] = dataclasses.field(
default_factory=_ClassifierOptions)
@doc_controls.do_not_generate_docs
def to_pb2(self) -> _TextClassifierGraphOptionsProto:

View File

@ -14,6 +14,7 @@
"""MediaPipe text embedder task."""
import dataclasses
from typing import Optional
from mediapipe.python import packet_creator
from mediapipe.python import packet_getter
@ -49,7 +50,8 @@ class TextEmbedderOptions:
embedder_options: Options for the text embedder task.
"""
base_options: _BaseOptions
embedder_options: _EmbedderOptions = _EmbedderOptions()
embedder_options: Optional[_EmbedderOptions] = dataclasses.field(
default_factory=_EmbedderOptions)
@doc_controls.do_not_generate_docs
def to_pb2(self) -> _TextEmbedderGraphOptionsProto:

View File

@ -181,9 +181,11 @@ class GestureRecognizerOptions:
min_hand_presence_confidence: Optional[float] = 0.5
min_tracking_confidence: Optional[float] = 0.5
canned_gesture_classifier_options: Optional[
_ClassifierOptions] = _ClassifierOptions()
_ClassifierOptions] = dataclasses.field(
default_factory=_ClassifierOptions)
custom_gesture_classifier_options: Optional[
_ClassifierOptions] = _ClassifierOptions()
_ClassifierOptions] = dataclasses.field(
default_factory=_ClassifierOptions)
result_callback: Optional[Callable[
[GestureRecognizerResult, image_module.Image, int], None]] = None

View File

@ -70,7 +70,8 @@ class ImageClassifierOptions:
"""
base_options: _BaseOptions
running_mode: _RunningMode = _RunningMode.IMAGE
classifier_options: _ClassifierOptions = _ClassifierOptions()
classifier_options: Optional[_ClassifierOptions] = dataclasses.field(
default_factory=_ClassifierOptions)
result_callback: Optional[Callable[
[ImageClassifierResult, image_module.Image, int], None]] = None

View File

@ -69,7 +69,8 @@ class ImageEmbedderOptions:
"""
base_options: _BaseOptions
running_mode: _RunningMode = _RunningMode.IMAGE
embedder_options: _EmbedderOptions = _EmbedderOptions()
embedder_options: Optional[_EmbedderOptions] = dataclasses.field(
default_factory=_EmbedderOptions)
result_callback: Optional[Callable[
[ImageEmbedderResult, image_module.Image, int], None]] = None