Skip to main content

Create topological graph for image segments

Project description

Create topological graph for image segments

PyPI Open In Colab

GraphVision

A library facilitating the generation of topological representations for image segments. The topological graph is created based on segments and visual embeddings as nodes. This segment topology retains not only spatial but also semantic information, making it very useful for various tasks in visual robotics[1] and localization.

GraphVision provides graphical representations that enable us to perform visual queries and interact with our segmentation graph without the usual preprocessing hassle. VisionGraph handles everything and also offers functionalities to visualize the segment topology and perform visual queries on the graph, leveraging Dijkstra's algorithm for localization..

Usage

The library requirements are flexible but still its suggested to use a virtual environment.

pip install graphvision

Read an Image

image_bgr = cv2.imread("image.jpg")
image_rgb = cv2.cvtColor(image_bgr, cv2.COLOR_BGR2RGB)

Initialize the generator, call the segmentation model, generate the masks and that is it! You are ready create the topological graph for your segments.

from graphvision import Generator, SegmentGraph
gen = Generator()
mask_gen = gen.SAM()
segments = gen.generate_masks(mask_gen, image_rgb)

You can use visualize or plot it using gen.plot_segments(segments)

Create the topological graph

sg = SegmentGraph(segments, image_rgb)
G, centroids = sg.get_topology(dist_thres=150) # Other Optional Parameters: area_percent, add_to_bbox

The graph G can be returned as a networkx (default) or as a PyTorch geometric object. This graphical representation can now be leveraged in various vision tasks such as object localization and environment mapping in robotics, based on both spatial and semantic features..

Query the segment graph

You can also perform visual queries on the graph to locate objects dependent on other nodes (neighbouring objects). This a naive implementation, so please go through the Colab notebook to understand to understand it in greateer detail.

result = sg.query_segment_graph(G, query_pair=("Girl", "plant"), show_legend=True)

Reference

  1. RoboHop: Segment-based Topological Map Representation for Open-World Visual Navigation

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

graphvision-0.1.3.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

graphvision-0.1.3-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file graphvision-0.1.3.tar.gz.

File metadata

  • Download URL: graphvision-0.1.3.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for graphvision-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5fc9dcda30a8ea9ed6727a5d04d98fb280859f4b53fe1f9b57e386e2c836e135
MD5 5cfd52197fec6a1ff7ba29219ec4dff7
BLAKE2b-256 2722c1d0c8307175bc88895bd1635cbc9ad24b0affceb9bcea4b0e458a6bc4b2

See more details on using hashes here.

File details

Details for the file graphvision-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: graphvision-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for graphvision-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6345f962570410d391e8799951b17e068f4779b035456860d29008bc85e57922
MD5 3605513612fb982760461f450ebe9760
BLAKE2b-256 f29546e677eff8f178857bc7700f2caf1d0ce68408d21a436dc8be3b97161ec3

See more details on using hashes here.

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