Skip to main content

Python library for detecting image objects with natural language text labels

Project description

CLIP_BBox

CLIP_BBox is a Python library for detecting image objects with natural language text labels.

Build Status codecov GitHub GitHub issues

Overview

CLIP is a neural network, pretrained on image-text pairs, that can predict the most relevant text snippet for a given image.

Given an image and a natural language text label, CLIP_BBox will obtain the image's spatial embedding and text label's embedding from CLIP, compute the similarity heatmap between the embeddings, then draw a bounding box around the image region with the highest image-text correspondence.

Features

The library will provide functions for the following operations:

  • Getting and appropriately reshaping an image's spatial embedding from the CLIP model before it performs attention-pooling
  • Getting a text snippet's embedding from the CLIP model
  • Computing the similarity heatmap between a pair of spatial and text embeddings from CLIP
  • Drawing bounding boxes on an image, given a similarity heatmap and a similarity threshold

Install

Use pip to install clip_bbox as a Python package:

$ pip install clip_bbox

Example Usage

Use As a Command Line Script

To draw bounding boxes on an image, run

$ python clip_bbox.py --img "path/to/img.png" 

Use As a Python Module

To draw bounding boxes on an image, do the following:

from clip_bbox import run_clip_bbox

run_clip_bbox('path/to/img.png')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clip_bbox-0.2.0.tar.gz (349.2 kB view hashes)

Uploaded Source

Built Distribution

clip_bbox-0.2.0-py3-none-any.whl (28.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page