وظیفه MediaPipe Image Embedder به شما امکان می دهد یک نمایش عددی از یک تصویر ایجاد کنید که در انجام وظایف مختلف تصویر مبتنی بر ML مفید است. این قابلیت اغلب برای مقایسه شباهت دو تصویر با استفاده از تکنیک های مقایسه ریاضی مانند شباهت کسینوس استفاده می شود. این وظیفه بر روی داده های تصویری با مدل یادگیری ماشینی (ML) به عنوان داده ایستا یا یک جریان پیوسته عمل می کند و یک نمایش عددی از داده های تصویر را به عنوان لیستی از بردارهای ویژگی با ابعاد بالا، که به عنوان بردارهای جاسازی نیز شناخته می شوند، به صورت شناور خروجی می دهد. شکل نقطه ای یا کوانتیزه شده
استفاده از این کار را با دنبال کردن یکی از این راهنماهای پیاده سازی برای پلتفرم هدف خود شروع کنید. این راهنماهای مخصوص پلتفرم شما را با استفاده از یک مدل توصیهشده، پیادهسازی اولیه این کار را راهنمایی میکنند و نمونههایی از کد را با گزینههای پیکربندی توصیهشده ارائه میکنند:
این بخش قابلیت ها، ورودی ها، خروجی ها و گزینه های پیکربندی این کار را شرح می دهد.
ویژگی ها
پردازش تصویر ورودی - پردازش شامل چرخش تصویر، تغییر اندازه، عادی سازی و تبدیل فضای رنگی است.
منطقه مورد علاقه - به جای کل تصویر، یک منطقه از تصویر را جاسازی می کند.
تعبیه محاسبات تشابه - تابع ابزار داخلی برای محاسبه شباهت کسینوس بین دو بردار ویژگی
Quantization - از کوانتیزهسازی اسکالر برای بردارهای ویژگی پشتیبانی میکند.
ورودی های وظیفه
خروجی های وظیفه
ورودی می تواند یکی از انواع داده های زیر باشد:
تصاویر ثابت
فریم های ویدئویی رمزگشایی شده
فید ویدیوی زنده
Image Embedder لیستی از جاسازیها شامل موارد زیر را خروجی میدهد:
جاسازی: خود بردار ویژگی، چه به صورت ممیز شناور و چه به صورت اسکالر کوانتیزه شده است.
نمایه سر: نمایه سر که این تعبیه را ایجاد کرده است.
نام سر (اختیاری): نام سر که این تعبیه را ایجاد کرده است.
گزینه های پیکربندی
این کار دارای گزینه های پیکربندی زیر است:
نام گزینه
توضیحات
محدوده ارزش
مقدار پیش فرض
running_mode
حالت اجرا را برای کار تنظیم می کند. سه حالت وجود دارد:
IMAGE: حالت برای ورودی های تک تصویر.
VIDEO: حالت برای فریم های رمزگشایی شده یک ویدیو.
LIVE_STREAM: حالت پخش زنده داده های ورودی، مانند دوربین. در این حالت، resultListener باید فراخوانی شود تا شنونده ای را برای دریافت نتایج به صورت ناهمزمان تنظیم کند.
{ IMAGE, VIDEO, LIVE_STREAM }
IMAGE
l2_normalize
آیا باید بردار ویژگی بازگشتی را با نرمال L2 عادی سازی کرد. فقط در صورتی از این گزینه استفاده کنید که مدل از قبل دارای یک L2_NORMALIZATION TFLite Op بومی نباشد. در بیشتر موارد، این قبلاً وجود دارد و بنابراین عادی سازی L2 از طریق استنتاج TFLite بدون نیاز به این گزینه حاصل می شود.
Boolean
False
quantize
اینکه آیا تعبیه برگشتی باید از طریق کوانتیزه کردن اسکالر به بایت تبدیل شود یا خیر. تعبیهها به طور ضمنی واحد هنجار فرض میشوند و بنابراین هر بعد تضمین میشود که مقداری در [-1.0، 1.0] داشته باشد. اگر اینطور نیست از گزینه l2_normalize استفاده کنید.
Boolean
False
result_callback
شنونده نتیجه را طوری تنظیم میکند که وقتی که Image Embedder در حالت پخش زنده است، نتایج جاسازی را به صورت ناهمزمان دریافت کند. فقط زمانی قابل استفاده است که حالت اجرا روی LIVE_STREAM تنظیم شده باشد
N/A
تنظیم نشده است
مدل ها
Image Embedder به یک مدل جاسازی تصویر نیاز دارد که دانلود و در فهرست پروژه شما ذخیره شود. هنگامی که شروع به توسعه با این کار می کنید، با مدل پیش فرض و توصیه شده برای پلتفرم هدف خود شروع کنید. سایر مدلهای موجود معمولاً بین عملکرد، دقت، وضوح و نیازهای منابع، معاوضه ایجاد میکنند و در برخی موارد، ویژگیهای اضافی را نیز شامل میشوند.
مدل MobileNetV3
این خانواده مدل از معماری MobileNet V3 استفاده می کند و با استفاده از داده های ImageNet آموزش داده شده است. این مدل از ضریب 0.75 برای عمق (تعداد ویژگی ها) در لایه های کانولوشن استفاده می کند تا مبادله دقت و تأخیر را تنظیم کند. علاوه بر این، MobileNet V3 در دو اندازه مختلف، کوچک و بزرگ، برای تطبیق شبکه با موارد استفاده کم یا زیاد از منابع ارائه میشود.
تاریخ آخرین بهروزرسانی 2025-01-13 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-01-13 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Image embedding task guide\n\nThe MediaPipe Image Embedder task lets you create a numeric representation of an image,\nwhich is useful in accomplishing various ML-based image tasks. This\nfunctionality is frequently used to compare the similarity of two images using\nmathematical comparison techniques such as Cosine Similarity. This task operates\non image data with a machine learning (ML) model as static data or a continuous\nstream, and outputs a numeric representation of the image data as a list of\nhigh-dimensional feature vectors, also known as embedding vectors, in either\nfloating-point or quantized form.\n\n[Try it!arrow_forward](https://mediapipe-studio.webapps.google.com/demo/image_embedder)\n\nGet Started\n-----------\n\nStart using this task by following one of these implementation guides for your\ntarget platform. These platform-specific guides walk you through a basic\nimplementation of this task, using a recommended model, and provide code\nexamples with the recommended configuration options:\n\n- **Android** - [Code\n example](https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/image_embedder/android) - [Guide](./android)\n- **Python** - [Code\n example](https://colab.sandbox.google.com/github/googlesamples/mediapipe/blob/main/examples/image_embedder/python/image_embedder.ipynb) - [Guide](./python)\n- **Web** - [Code example](https://codepen.io/mediapipe-preview/pen/yLqxbaZ) - [Guide](./web_js)\n\nTask details\n------------\n\nThis section describes the capabilities, inputs, outputs, and configuration\noptions of this task.\n\n### Features\n\n- **Input image processing** - Processing includes image rotation, resizing, normalization, and color space conversion.\n- **Region of interest** - Performs embedding on a region of the image instead of the whole image.\n- **Embedding similarity computation** - Built-in utility function to compute the [cosine similarity](https://en.wikipedia.org/wiki/Cosine_similarity) between two feature vectors\n- **Quantization** - Supports scalar quantization for the feature vectors.\n\n| Task inputs | Task outputs |\n|-------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Input can be one of the following data types: - Still images \u003c!-- --\u003e - Decoded video frames \u003c!-- --\u003e - Live video feed | Image Embedder outputs a list of embeddings consisting of: - Embedding: the feature vector itself, either in floating-point form or scalar-quantized. \u003c!-- --\u003e - Head index: the index for the head that produced this embedding. \u003c!-- --\u003e - Head name (optional): the name of the head that produced this embedding. |\n\n### Configurations options\n\nThis task has the following configuration options:\n\n| Option Name | Description | Value Range | Default Value |\n|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------|---------------|\n| `running_mode` | Sets the running mode for the task. There are three modes: \u003cbr /\u003e IMAGE: The mode for single image inputs. \u003cbr /\u003e VIDEO: The mode for decoded frames of a video. \u003cbr /\u003e LIVE_STREAM: The mode for a livestream of input data, such as from a camera. In this mode, resultListener must be called to set up a listener to receive results asynchronously. | {`IMAGE, VIDEO, LIVE_STREAM`} | `IMAGE` |\n| `l2_normalize` | Whether to normalize the returned feature vector with L2 norm. Use this option only if the model does not already contain a native L2_NORMALIZATION TFLite Op. In most cases, this is already the case and L2 normalization is thus achieved through TFLite inference with no need for this option. | `Boolean` | `False` |\n| `quantize` | Whether the returned embedding should be quantized to bytes via scalar quantization. Embeddings are implicitly assumed to be unit-norm and therefore any dimension is guaranteed to have a value in \\[-1.0, 1.0\\]. Use the l2_normalize option if this is not the case. | `Boolean` | `False` |\n| `result_callback` | Sets the result listener to receive the embedding results asynchronously when the Image Embedder is in the live stream mode. Can only be used when running mode is set to `LIVE_STREAM` | N/A | Not set |\n\n| **Note:** The `resultListener` is dependent on `runningMode`. Only set the `resultListener` when `runningMode` is set to `LIVE_STREAM`.\n\nModels\n------\n\nThe Image Embedder requires an image embedding model to be downloaded and stored\nin your project directory. Start with the default, recommended model for your\ntarget platform when you start developing with this task. The other available\nmodels typically make trade-offs between performance, accuracy, resolution, and\nresource requirements, and in some cases, include additional features.\n| **Attention:** This MediaPipe Solutions Preview is an early release. [Learn more](/edge/mediapipe/solutions/about#notice).\n\n### MobileNetV3 model\n\nThis model family uses a [MobileNet V3](https://arxiv.org/abs/1905.02244)\narchitecture and was trained using [ImageNet](https://www.image-net.org) data.\nThis model uses a multiplier of 0.75 for the depth (number of features) in the\nconvolutional layers to tune the accuracy-latency trade off. In addition,\nMobileNet V3 comes in two different sizes, small and large, to adapt the network\nto low or high resource use cases.\n\n| Model name | Input shape | Quantization type | Versions |\n|----------------------------------------------------------------------------------------------------------------------------------------------------|-------------|-------------------|--------------------------------------------------------------------------------------------------------------------------------------|\n| [MobileNet-V3 (small)](https://storage.googleapis.com/mediapipe-models/image_embedder/mobilenet_v3_small/float32/latest/mobilenet_v3_small.tflite) | 224 x 224 | None (float32) | [Latest](https://storage.googleapis.com/mediapipe-models/image_embedder/mobilenet_v3_small/float32/latest/mobilenet_v3_small.tflite) |\n| [MobileNet-V3 (large)](https://storage.googleapis.com/mediapipe-models/image_embedder/mobilenet_v3_large/float32/latest/mobilenet_v3_large.tflite) | 224 x 224 | None (float32) | [Latest](https://storage.googleapis.com/mediapipe-models/image_embedder/mobilenet_v3_large/float32/latest/mobilenet_v3_large.tflite) |\n\nTask benchmarks\n---------------\n\nHere's the task benchmarks for the whole pipeline based on the above\npre-trained models. The latency result is the average latency on Pixel 6 using\nCPU / GPU.\n\n| Model Name | CPU Latency | GPU Latency |\n|----------------------|-------------|-------------|\n| MobileNet-V3 (small) | 3.94ms | 7.83ms |\n| MobileNet-V3 (large) | 9.75ms | 9.08ms |"]]