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

Updated 3 years ago

image-embedding

Image Embedding with Timm

author: Jael Gu, Filip

Desription

An image embedding operator implemented with pretrained models provided by Timm.

from towhee import ops
import numpy as np

img_encoder = ops.image_embedding.timm('resnet50')
fake_img = np.zeros((256, 256, 3))
image_embedding = img_encoder(fake_img)

Factory Constructor

Create the operator via the following factory method

ops.image_embedding.timm(model_name)

Interface

An image embedding operator takes an image in ndarray as input. It uses the pre-trained model specified by model name to generate an image embedding in ndarray.

Parameters:

img: numpy.ndarray

​ The decoded image data in numpy.ndarray.

Returns: numpy.ndarray

​ The image embedding extracted by model.

Code Example

Load an image from path './dog.jpg' and use the pretrained ResNet50 model ('resnet50') to generate an image embedding.

Write the pipeline in simplified style:

import towhee.DataCollection as dc

dc.glob(./dog.jpg)
  .image_decode()
  .image_embedding.timm('resnet50')
  .show()

Write a same pipeline with explicit inputs/outputs name specifications:

from towhee import DataCollection as dc

dc.glob['path'](./dog.jpg)
  .image_decode['path', 'img']()
  .image_embedding.timm['img', 'vec']('resnet50')
  .select('img')
  .show()
Jael Gu a04940fb30 Update 5 Commits
file-icon .gitattributes
1.1 KiB
download-icon
Initial commit 3 years ago
file-icon README.md
1.4 KiB
download-icon
Update README 3 years ago
file-icon __init__.py
664 B
download-icon
Refactor 3 years ago
file-icon requirements.txt
18 B
download-icon
Add 3 years ago
file-icon timm_image.py
2.8 KiB
download-icon
Update 3 years ago