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 8 months ago

image-embedding

Image Embdding with DOLG

author: David Wang


Description

This operator extracts features for image with DOLG which has special design for image retrieval task. It integrates local and global information inside images into compact image representations. This operator is an adaptation from dongkyuk/DOLG-pytorch.


Code Example

Load an image from path './towhee.jpg' to generate an image embedding.

Write the pipeline in simplified style:

import towhee

towhee.glob('./towhee.jpg') \
      .image_decode.cv2() \
      .image_embedding.dolg(img_size=512, input_dim=3, hidden_dim=1024, output_dim=2048) \
      .show()

result1

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

import towhee

towhee.glob['path']('./towhee.jpg') \
      .image_decode.cv2['path', 'img']() \
      .image_embedding.dolg['img', 'vec'](img_size=512, input_dim=3, hidden_dim=1024, output_dim=2048) \
      .select['img', 'vec']() \
      .show()
result2


Factory Constructor

Create the operator via the following factory method

image_embedding.dolg(img_size=512, input_dim=3, hidden_dim=1024, output_dim=2048)

Parameters:

img_size: int

​ Scaled input image size to extract embedding. The higher resolution would generate the more discriminateive feature but cost more time to calculate.

input_dim: int

​ The input dimension of DOLG module (equals pretrained cnn output dimension).

hidden_dim: int

​ The hidden dimension size, local feature branch output dimension.

output_dim: int

​ The output dimsion size, same as embedding size.


Interface

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

Parameters:

img: towhee.types.Image (a sub-class of numpy.ndarray)

​ The decoded image data in towhee.types.Image (numpy.ndarray).

Returns: numpy.ndarray

​ The image embedding extracted by model.

More Resources

Jael Gu 9e07f3072a Add more resources 7 Commits
file-icon .gitattributes
1.1 KiB
download-icon
Initial commit 3 years ago
file-icon README.md
4.0 KiB
download-icon
Add more resources 8 months ago
file-icon __init__.py
761 B
download-icon
init the dolg. 3 years ago
file-icon dolg.py
1.8 KiB
download-icon
remove the transforms.Scale. 3 years ago
file-icon dolg_impl.py
4.6 KiB
download-icon
init the dolg. 3 years ago
file-icon requirements.txt
30 B
download-icon
remove the transforms.Scale. 3 years ago
file-icon result1.png
11 KiB
download-icon
init the dolg. 3 years ago
file-icon result2.png
160 KiB
download-icon
init the dolg. 3 years ago