Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ iOS), web, desktop, edge devices, and IoT, effortlessly.

## Get started

You can get started with MediaPipe Solutions by by checking out any of the
You can get started with MediaPipe Solutions by checking out any of the
developer guides for
[vision](https://developers.google.com/mediapipe/solutions/vision/object_detector),
[text](https://developers.google.com/mediapipe/solutions/text/text_classifier),
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ iOS), web, desktop, edge devices, and IoT, effortlessly.

## Get started

You can get started with MediaPipe Solutions by by checking out any of the
You can get started with MediaPipe Solutions by checking out any of the
developer guides for
[vision](https://developers.google.com/mediapipe/solutions/vision/object_detector),
[text](https://developers.google.com/mediapipe/solutions/text/text_classifier),
Expand Down
6 changes: 3 additions & 3 deletions mediapipe/python/pybind/calculator_graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void CalculatorGraphSubmodule(pybind11::module* module) {

Raises:
FileNotFoundError: If the binary graph file can't be found.
ValueError: If the input arguments prvoided are more than needed or the
ValueError: If the input arguments provided are more than needed or the
graph validation process contains error.
)doc");

Expand Down Expand Up @@ -202,7 +202,7 @@ void CalculatorGraphSubmodule(pybind11::module* module) {
graph.add_packet_to_input_stream(
stream='in',
packet=packet_creator.create_string('hello world'),
timstamp=1)
timestamp=1)
)doc",
py::arg("stream"), py::arg("packet"),
py::arg("timestamp") = Timestamp::Unset());
Expand Down Expand Up @@ -461,7 +461,7 @@ void CalculatorGraphSubmodule(pybind11::module* module) {
R"doc(Get output side packet by name after the graph is done.

Args:
stream: The name of the outnput stream.
stream: The name of the output stream.

Raises:
RuntimeError: If the graph is still running or the output side packet is not
Expand Down
4 changes: 2 additions & 2 deletions mediapipe/python/pybind/packet_creator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ void PublicPacketCreators(pybind11::module* m) {
A MediaPipe double Packet.

Raises:
TypeError: If the input is neither a float nore a np.double.
TypeError: If the input is neither a float nor a np.double.

Examples:
packet = mp.packet_creator.create_double(0.1)
Expand Down Expand Up @@ -702,7 +702,7 @@ void InternalPacketCreators(pybind11::module* m) {
// TODO: Implement this.
throw RaisePyError(PyExc_NotImplementedError,
"Creating a packet from a vector of proto messages "
"is not supproted yet.");
"is not supported yet.");
return Packet();
},
py::return_value_policy::move);
Expand Down
2 changes: 1 addition & 1 deletion mediapipe/python/pybind/packet_getter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ void InternalPacketGetters(pybind11::module* m) {
// https://github.com/pybind/pybind11/issues/1236
// However, when Pybind11 performs the C++ to Python transition, it
// only increases the py::bytes object's ref count. See the
// implmentation at line 1583 in "pybind11/cast.h".
// implementation at line 1583 in "pybind11/cast.h".
return py::bytes(packet.GetProtoMessageLite().SerializeAsString());
},
py::return_value_policy::move);
Expand Down
2 changes: 1 addition & 1 deletion mediapipe/python/pybind/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ inline void RaisePyErrorIfNotOk(const absl::Status& status,
inline void RaisePyErrorIfOverflow(int64_t value, int64_t min, int64_t max) {
if (value > max) {
throw RaisePyError(PyExc_OverflowError,
absl::StrCat(value, " execeeds the maximum value (", max,
absl::StrCat(value, " exceeds the maximum value (", max,
") the data type can have.")
.c_str());
} else if (value < min) {
Expand Down
2 changes: 1 addition & 1 deletion mediapipe/python/pybind/validated_graph_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void ValidatedGraphConfigSubmodule(pybind11::module* module) {

Raises:
FileNotFoundError: If the binary graph file can't be found.
ValueError: If the input arguments prvoided are more than needed or the
ValueError: If the input arguments provided are more than needed or the
graph validation process contains error.

Examples:
Expand Down
2 changes: 1 addition & 1 deletion mediapipe/tasks/cc/core/model_resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ModelResources {
// Takes the ownership of the provided ExternalFile proto and creates
// ModelResources from the proto and an op resolver mediapipe packet. A
// non-empty tag must be set if the ModelResources will be used through
// ModelResourcesCacheService. The op resolver packet, usually prvoided by a
// ModelResourcesCacheService. The op resolver packet, usually provided by a
// ModelResourcesCacheService object, contains the TFLite op resolvers
// required by the model.
static absl::StatusOr<std::unique_ptr<ModelResources>> Create(
Expand Down
2 changes: 1 addition & 1 deletion mediapipe/tasks/cc/vision/image_embedder/image_embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class ImageEmbedder : core::BaseVisionTaskApi {
// sent to the object detector. The input timestamps must be monotonically
// increasing.
//
// The "result_callback" prvoides
// The "result_callback" provides
// - The embedding results as a
// components::containers::proto::EmbeddingResult object.
// - The const reference to the corresponding input image that the image
Expand Down
11 changes: 5 additions & 6 deletions mediapipe/tasks/python/audio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@

"""MediaPipe Tasks Audio API."""

import mediapipe.tasks.python.audio.core
import mediapipe.tasks.python.audio.audio_classifier
import mediapipe.tasks.python.audio.audio_embedder
import mediapipe.tasks.python.audio.core.audio_task_running_mode as audio_task_running_mode
import mediapipe.tasks.python.audio.audio_classifier as audio_classifier
import mediapipe.tasks.python.audio.audio_embedder as audio_embedder

AudioClassifier = audio_classifier.AudioClassifier
AudioClassifierOptions = audio_classifier.AudioClassifierOptions
AudioClassifierResult = audio_classifier.AudioClassifierResult
AudioEmbedder = audio_embedder.AudioEmbedder
AudioEmbedderOptions = audio_embedder.AudioEmbedderOptions
AudioEmbedderResult = audio_embedder.AudioEmbedderResult
RunningMode = core.audio_task_running_mode.AudioTaskRunningMode
RunningMode = audio_task_running_mode.AudioTaskRunningMode

# Remove unnecessary modules to avoid duplication in API docs.
del audio_classifier
del audio_embedder
del core
del mediapipe
del audio_task_running_mode
2 changes: 1 addition & 1 deletion mediapipe/tasks/python/audio/audio_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def classify_async(self, audio_block: _AudioData, timestamp_ms: int) -> None:
for adjacent calls of this method. This method will return immediately after
the input audio data is accepted. The results will be available via the
`result_callback` provided in the `AudioClassifierOptions`. The
`classify_async` method is designed to process auido stream data such as
`classify_async` method is designed to process audio stream data such as
microphone input.

The input audio data may be longer than what the model is able to process
Expand Down
2 changes: 1 addition & 1 deletion mediapipe/tasks/python/audio/audio_embedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def embed_async(self, audio_block: _AudioData, timestamp_ms: int) -> None:
for adjacent calls of this method. This method will return immediately after
the input audio data is accepted. The results will be available via the
`result_callback` provided in the `AudioEmbedderOptions`. The
`embed_async` method is designed to process auido stream data such as
`embed_async` method is designed to process audio stream data such as
microphone input.

The input audio data may be longer than what the model is able to process
Expand Down
4 changes: 2 additions & 2 deletions mediapipe/tasks/python/audio/core/base_audio_task_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(
'callback should not be provided.')
self._runner = _TaskRunner.create(graph_config, packet_callback)
self._running_mode = running_mode
self._default_sample_rate = None
self._default_sample_rate: Optional[float] = None

def _process_audio_clip(
self, inputs: Mapping[str, _Packet]) -> Mapping[str, _Packet]:
Expand Down Expand Up @@ -142,7 +142,7 @@ def create_audio_record(

Note that MediaPipe Audio tasks will up/down sample automatically to fit the
sample rate required by the model. The default sample rate of the MediaPipe
pretrained audio model, Yamnet is 16kHz.
pretrained audio model, YAMNet is 16kHz.

Args:
num_channels: The number of audio channels.
Expand Down
24 changes: 12 additions & 12 deletions mediapipe/tasks/python/benchmark/benchmark_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_test_data_path(test_srcdir, file_or_dirname_path: str) -> str:
if path.endswith(file_or_dirname_path):
return path
raise ValueError(
"No %s in test directory: %s." % (file_or_dirname_path, test_srcdir)
f"No {file_or_dirname_path} in test directory: {test_srcdir}."
)


Expand All @@ -57,14 +57,14 @@ def get_model_path(custom_model, default_model_path):
Returns:
The path to the model to be used.
"""
if custom_model is not None and os.path.exists(custom_model):
print(f"Using provided model: {custom_model}")
return custom_model
else:
if custom_model is not None:
print(
f"Warning: Provided model '{custom_model}' not found. "
"Using default model instead."
)
print(f"Using default model: {default_model_path}")
return default_model_path
if custom_model is not None:
if os.path.exists(custom_model):
print(f"Using provided model: {custom_model}")
return custom_model
print(
f"Warning: Provided model '{custom_model}' not found. "
"Using default model instead."
)

print(f"Using default model: {default_model_path}")
return default_model_path
19 changes: 9 additions & 10 deletions mediapipe/tasks/python/components/containers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

"""MediaPipe Tasks Components Containers API."""

import mediapipe.tasks.python.components.containers.audio_data
import mediapipe.tasks.python.components.containers.bounding_box
import mediapipe.tasks.python.components.containers.category
import mediapipe.tasks.python.components.containers.classification_result
import mediapipe.tasks.python.components.containers.detections
import mediapipe.tasks.python.components.containers.embedding_result
import mediapipe.tasks.python.components.containers.landmark
import mediapipe.tasks.python.components.containers.landmark_detection_result
import mediapipe.tasks.python.components.containers.rect
import mediapipe.tasks.python.components.containers.audio_data as audio_data
import mediapipe.tasks.python.components.containers.bounding_box as bounding_box
import mediapipe.tasks.python.components.containers.category as category
import mediapipe.tasks.python.components.containers.classification_result as classification_result
import mediapipe.tasks.python.components.containers.detections as detections
import mediapipe.tasks.python.components.containers.embedding_result as embedding_result
import mediapipe.tasks.python.components.containers.landmark as landmark
import mediapipe.tasks.python.components.containers.landmark_detection_result as landmark_detection_result
import mediapipe.tasks.python.components.containers.rect as rect

AudioDataFormat = audio_data.AudioDataFormat
AudioData = audio_data.AudioData
Expand Down Expand Up @@ -50,4 +50,3 @@
del landmark
del landmark_detection_result
del rect
del mediapipe
3 changes: 1 addition & 2 deletions mediapipe/tasks/python/components/processors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

"""MediaPipe Tasks Components Processors API."""

import mediapipe.tasks.python.components.processors.classifier_options
import mediapipe.tasks.python.components.processors.classifier_options as classifier_options

ClassifierOptions = classifier_options.ClassifierOptions

# Remove unnecessary modules to avoid duplication in API docs.
del classifier_options
del mediapipe
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _compute_cosine_similarity(u: np.ndarray, v: np.ndarray):
"""Computes cosine similarity between two embeddings."""

if len(u) <= 0:
raise ValueError("Cannot compute cosing similarity on empty embeddings.")
raise ValueError("Cannot compute cosine similarity on empty embeddings.")

norm_u = np.linalg.norm(u)
norm_v = np.linalg.norm(v)
Expand Down
14 changes: 7 additions & 7 deletions mediapipe/tasks/python/core/pybind/task_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ mode) or not (synchronous mode).)doc");
#if !MEDIAPIPE_DISABLE_GPU
auto gpu_resources_ = mediapipe::GpuResources::Create();
if (!gpu_resources_.ok()) {
ABSL_LOG(INFO) << "GPU suport is not available: "
ABSL_LOG(INFO) << "GPU support is not available: "
<< gpu_resources_.status();
gpu_resources_ = nullptr;
}
Expand All @@ -91,7 +91,7 @@ mode) or not (synchronous mode).)doc");
absl::make_unique<core::MediaPipeBuiltinOpResolver>(),
std::move(callback),
/* default_executor= */ nullptr,
/* input_side_packes= */ std::nullopt, std::move(*gpu_resources_));
/* input_side_packets= */ std::nullopt, std::move(*gpu_resources_));
#else
auto task_runner = TaskRunner::Create(
std::move(graph_config),
Expand All @@ -117,7 +117,7 @@ provide the input packets and receive the output packets.
Raises:
RuntimeError: Any of the following:
a) The graph config proto is invalid.
b) The underlying medipaipe graph fails to initialize and start.
b) The underlying mediapipe graph fails to initialize and start.
)doc",
py::arg("graph_config"), py::arg("packets_callback") = py::none());

Expand Down Expand Up @@ -155,7 +155,7 @@ threads and to ensure that the input packet timestamps are in order.
RuntimeError: Any of the following:
a) TaskRunner is in the asynchronous mode (the packets callback is set).
b) Any input stream name is not valid.
c) The underlying medipaipe graph occurs any error during this call.
c) The underlying mediapipe graph occurs any error during this call.
)doc",
py::arg("input_packets"));

Expand Down Expand Up @@ -191,7 +191,7 @@ the input packet timestamps are in order.
queue size or the wrong packet type.
d) The timestamp of any packet is invalid or is not greater than the
previously received timestamps.
e) The underlying medipaipe graph occurs any error during adding input
e) The underlying mediapipe graph occurs any error during adding input
packets.
)doc",
py::arg("input_packets"));
Expand All @@ -208,7 +208,7 @@ After the runner is closed, any calls that send input data to the runner are
illegal and will receive errors.

Raises:
RuntimeError: The underlying medipaipe graph fails to close any input streams
RuntimeError: The underlying mediapipe graph fails to close any input streams
or calculators.
)doc");

Expand All @@ -223,7 +223,7 @@ illegal and will receive errors.
This can be useful for resetting a stateful task graph to process new data.

Raises:
RuntimeError: The underlying medipaipe graph fails to reset and restart.
RuntimeError: The underlying mediapipe graph fails to reset and restart.
)doc");

task_runner.def(
Expand Down
2 changes: 1 addition & 1 deletion mediapipe/tasks/python/genai/bundler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"""MediaPipe Tasks GenAI Bundler API."""

import mediapipe.tasks.python.genai.bundler.llm_bundler
import mediapipe.tasks.python.genai.bundler.llm_bundler as llm_bundler

BundleConfig = llm_bundler.BundleConfig
create_bundle = llm_bundler.create_bundle
Expand Down
4 changes: 2 additions & 2 deletions mediapipe/tasks/python/genai/bundler/llm_bundler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import enum
from typing import List, Optional

import sentencepiece
from mediapipe.tasks.python.metadata.metadata_writers import model_asset_bundle_utils
from mediapipe.tasks.cc.genai.inference.proto import llm_params_pb2
import sentencepiece


@dataclasses.dataclass(frozen=True)
Expand All @@ -30,7 +30,7 @@ class BundleConfig:
Attributes:
tflite_model: Path to the multi-signature tflite model with "prefill" and
"decode" signatures converted using ODML Transformers APIs.
tokenizer_model: Path to the tokenizer model. Currently only SentencePience
tokenizer_model: Path to the tokenizer model. Currently only SentencePiece
tokenizer is supported. As such, tokenizer.model proto is expected to be
passed here.
start_token: Token that will be used to signify the beginning of a sequence.
Expand Down
4 changes: 2 additions & 2 deletions mediapipe/tasks/python/genai/bundler/llm_bundler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import zipfile

from absl.testing import absltest
from sentencepiece import sentencepiece_model_pb2

from mediapipe.tasks.python.genai.bundler import llm_bundler
from sentencepiece import sentencepiece_model_pb2


class LlmBundlerTest(absltest.TestCase):
Expand Down Expand Up @@ -127,7 +127,7 @@ def test_invalid_stop_tokens_raises_value_error(self):
tflite_model=tflite_file_path,
tokenizer_model=sp_file_path,
start_token=self.BOS,
stop_tokens=self.EOS,
stop_tokens=[self.EOS],
output_filename=output_file,
)
with self.assertRaisesRegex(
Expand Down
3 changes: 1 addition & 2 deletions mediapipe/tasks/python/genai/converter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@

"""MediaPipe Tasks GenAI Converter API."""

import mediapipe.tasks.python.genai.converter.llm_converter
import mediapipe.tasks.python.genai.converter.llm_converter as llm_converter

ConversionConfig = llm_converter.ConversionConfig
convert_checkpoint = llm_converter.convert_checkpoint

# Remove unnecessary modules to avoid duplication in API docs.
del mediapipe
del llm_converter
3 changes: 1 addition & 2 deletions mediapipe/tasks/python/genai/converter/converter_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@

"""Defines a couple base classes for the conversion/quantization process."""

from typing import Iterator
import os
from typing import Dict, List, Optional, Tuple
from typing import Dict, List, Optional, Tuple, Iterator
import numpy as np


Expand Down
Loading