OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Models

Img2Vec

Img2Vec is a Python library that uses pretrained PyTorch vision models to extract fixed-length feature vectors from images. Developers can use those vectors in downstream tasks such as image similarity, recommender ranking, clustering, classification and compression experiments.

Independent OpenViST project profile, based on linked sources.

Img2Vec — Using a single image or a list of Pillow images as input
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use Img2Vec when a Python project needs fixed-length image representations from pretrained vision models rather than implementing feature extraction from scratch.

Who it is for

  • Python developers building image-feature workflows with PyTorch
  • Teams that need image vectors as inputs to similarity, ranking, clustering or classification systems

Documented uses

  • Extract a feature vector from one image or a list of images.
  • Compare images using vector-based similarity in the supplied example.
  • Provide image representations for downstream recommendation ranking, clustering, classification or compression work.
Before you choose

Requirements & limits

  • The listed model determines the vector length, ranging from 512 for ResNet-18 to 4,096 for AlexNet and VGG variants.
  • PyTorch is required; torchvision is part of the installation instructions, and Pillow and scikit-learn are additional requirements for the example.
  • GPU use is configurable and defaults to off.
  • The README's stated tested environment is Python 3.6 with torchvision 0.11.0 nightly from 2021; this is not a guarantee for other setups.
  • The repository metadata specifies an MIT license.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Set up Img2Vec and extract an image vector

Install the library and use its documented Python interface to obtain a vector from an RGB image.

Before you start

  • Python environment with PyTorch and torchvision
  • The img2vec_pytorch package
  • Pillow for opening the image

Steps

  1. Install torchvision and the img2vec_pytorch package using the README's listed installation commands.

  2. Import Img2Vec and Pillow, then initialize Img2Vec with the desired GPU setting.

  3. Open an RGB image with Pillow and call get_vec; request tensor=True if a PyTorch FloatTensor is wanted.

Expected outcome

A fixed-length feature vector for the image, returned as a PyTorch tensor when requested.

Guide limitations

  • The README's installation notes cite Python 3.6 and torchvision 0.11.0 nightly from 2021; they do not establish compatibility with other environments.
  • GPU use is optional and defaults to False.
Source-based practical guide

Run the documented image-similarity example

Use the repository example to compare image vectors and display similar filenames.

Before you start

  • Python environment with the library and its dependencies
  • Pillow and scikit-learn, listed as additional requirements for the example
  • The repository example and image files

Steps

  1. Clone the repository and change into its example directory.

  2. Run the documented test_img_similarity.py example.

  3. Enter an image filename when prompted to view the example's similarity results.

Expected outcome

The example prints ranked image filenames with similarity scores for the selected image.

Guide limitations

  • The README presents example output for sample images; it does not establish results for other image sets.
  • The example requires scikit-learn in addition to Pillow.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
8 November 2026
Original website title
christiansafka/img2vec · Official homepage title · retained in its source language