Create topological graph for image segments
Project description
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
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
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fc9dcda30a8ea9ed6727a5d04d98fb280859f4b53fe1f9b57e386e2c836e135 |
|
MD5 | 5cfd52197fec6a1ff7ba29219ec4dff7 |
|
BLAKE2b-256 | 2722c1d0c8307175bc88895bd1635cbc9ad24b0affceb9bcea4b0e458a6bc4b2 |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6345f962570410d391e8799951b17e068f4779b035456860d29008bc85e57922 |
|
MD5 | 3605513612fb982760461f450ebe9760 |
|
BLAKE2b-256 | f29546e677eff8f178857bc7700f2caf1d0ce68408d21a436dc8be3b97161ec3 |