logo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions

96 lines
4.0 KiB

# Image Embedding Pipeline
## **Description**
An image embedding pipeline generates a vector given an image. This Pipeline extracts features for image with 'ResNet50' models provided by [Timm](https://github.com/rwightman/pytorch-image-models). Timm is a deep-learning library developed by [Ross Wightman](https://twitter.com/wightmanr), who maintains SOTA deep-learning models and tools in computer vision.
<br />
## Code Example
### Create pipeline with the default configuration
```python
from towhee import AutoPipes
p = AutoPipes.pipeline('image-embedding')
res = p('https://github.com/towhee-io/towhee/raw/main/towhee_logo.png')
res.get()
```
### Create pipeline and set the configuration
> More parameters refer to the Configuration.
```python
from towhee import AutoPipes, AutoConfig
conf = AutoConfig.load_config('image-embedding')
conf.model_name = 'resnet34'
p = AutoPipes.pipeline('image-embedding', conf)
res = p('https://github.com/towhee-io/towhee/raw/main/towhee_logo.png')
res.get()
```
<br />
## **Configuration**
### **ImageEmbeddingConfig**
> You can find some parameters in [image_decode.cv2](https://towhee.io/image-decode/cv2) and [image_embedding.timm](https://towhee.io/image-embedding/timm) operators.
***mode:*** str
The mode for image, 'BGR' or 'RGB', defaults to 'BGR'.
***model_name:*** *str*
The model name in string. The default value is "resnet50". Refer to [Timm Docs](https://fastai.github.io/timmdocs/#List-Models-with-Pretrained-Weights) to get a full list of supported models.
***num_classes:*** *int*
The number of classes. The default value is 1000. It is related to model and dataset.
***skip_preprocess:*** *bool*
The flag to control whether to skip image pre-process. The default value is False. If set to True, it will skip image preprocessing steps (transforms). In this case, input image data must be prepared in advance in order to properly fit the model.
***device***: int
The number of GPU device, defaults to -1, which means using CPU.
<br />
## Interface
Encode the image and generate embedding vectors.
**Parameters:**
***img***: str
Path or url of the image to be loaded.
**Returns:** np.ndarray
Embedding vectors to represent the image.
2 years ago
# More Resources
- [How to Get the Right Vector Embeddings - Zilliz blog](https://zilliz.com/blog/how-to-get-the-right-vector-embeddings): A comprehensive introduction to vector embeddings and how to generate them with popular open-source models.
- [Supercharged Semantic Similarity Search in Production - Zilliz blog](https://zilliz.com/learn/supercharged-semantic-similarity-search-in-production): Building a Blazing Fast, Highly Scalable Text-to-Image Search with CLIP embeddings and Milvus, the most advanced open-source vector database.
- [What Are Vector Embeddings?](https://zilliz.com/glossary/vector-embeddings): Learn the definition of vector embeddings, how to create vector embeddings, and more.
- [Chose from six embedding models in Zilliz Cloud Pipelines - Zilliz blog](https://zilliz.com/blog/zilliz-cloud-pipelines-feb-release): Zilliz Cloud Pipelines releases exciting new updates in February including the addition of 3rd party embedding models from OpenAI and Voyage AI.
- [Understanding Neural Network Embeddings - Zilliz blog](https://zilliz.com/learn/understanding-neural-network-embeddings): This article is dedicated to going a bit more in-depth into embeddings/embedding vectors, along with how they are used in modern ML algorithms and pipelines.
- [Image Embeddings for Enhanced Image Search - Zilliz blog](https://zilliz.com/learn/image-embeddings-for-enhanced-image-search): Image Embeddings are the core of modern computer vision algorithms. Understand their implementation and use cases and explore different image embedding models.
- [An Introduction to Vector Embeddings: What They Are and How to Use Them - Zilliz blog](https://zilliz.com/learn/everything-you-should-know-about-vector-embeddings): In this blog post, we will understand the concept of vector embeddings and explore its applications, best practices, and tools for working with embeddings.