Skip to main content

GeomPrompt

GeomPrompt is a tool for generating point prompts of multi-scale ridge like features for subsequent use with image segmenters like Segment Anything Model (SAM). GeomPrompt seeks to distribute a user-specified number of point prompts evenly across salient ridge features. The tool was designed to support automated segmentation of plant roots in minirhizotron and rhizotron-type images, however it can be applied to alternate tasks requiring the segmentation of "ridge-like" features. Local ridge-like regions are determined as a function the Hessian after applying a Gaussian filter at varying scales.

See the Documentation at http://rootshape.pages.geomdata.com/geomprompt

Installation

If you just want to run the software, do any of these:

  • For the official, stable published version, use pip install geomprompt
  • For more advanced or customized development options, as well as developer installation instructions, see CONTRIBUTING.md and DEPENDENCIES.md.

Usage

While GeomPrompt can be utilized to generate point prompts of salient ridge (or valley) like features for general purposes, its outputs are customized to be directly utilized as prompt points for SAM. GeomPrompt's primary interface is the geomprompt.ridges.RidgePrompts class, which can be initialized with a target image (when initialized in this way scale space ridge test values are computed for the specific image). The initializing image can be grayscale (1-channel) or RGB (3-channel); in the latter case RidgePrompts uses skimage.color.rgb2gray to convert the image to grayscale.

import numpy as np
from skimage.data import coffee
from geomprompt.ridges.ridge_prompts import RidgePrompts

prompter = RidgePrompts(coffee())
ridge_prompts = prompter.get_prompts(32)

In the above, prompter returns 32 "salient" ridge prompt points. ridge_prompts is a dictionary with keys batch_prompt_points, batch_point_lables, and automask_prompts. batch_prompt_points interfaces with SAM's batch prompting and prompt points are in the native image coordinate space. automask_prompts interface with SAM's SamAutomaticMaskGenerator and are scaled to percentages of the image dimensions.

Prompts can be used directly with SAM assuming segment-anything is installed in the environment and a SAM checkpoint is accessible.

from segment_anything import SamAutomaticMaskGenerator, sam_model_registry

sam_checkpoint = "<path/to/sam_vit_h_4b8939.pth>"
model_type = "vit_h"
device = "cpu" # "cuda"
sam = sam_model_registry[model_type](checkpoint=sam_checkpoint)
sam.to(device=device)

sam_geom = SamAutomaticMaskGenerator(
    model=sam,
    pred_iou_thresh=0.6,
    stability_score_thresh=0.8,
    points_per_side=None,
    point_grids=ridge_prompts["automask_prompts"],
)

geom_masks = sam_geom.generate(np.array(coffee()))

Usage of the resulting geom_masks is documented in segment-anything.

Features

  • pip installable
  • testing suite with pytest
  • documentation with sphinx
  • tests and deployment integrated with gitlab CI/CD

Credits

This package was initialized with cookiecutter and the GDA Cookiecutter project template.

Metadata

Release files for geomprompt 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for geomprompt 0.2.5
File Size Uploaded
geomprompt-0.2.5.tar.gz 50.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for geomprompt 0.2.5
File Interpreter ABI Platform
geomprompt-0.2.5-py3-none-any.whl Python 3 none any Details

Total release size: 75.8 kB

Release files / geomprompt-0.2.5.tar.gz

Download URL geomprompt-0.2.5.tar.gz
Size 50.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3c8c893b192381b77da2c09b593ac7fc47b1c4f0b925d1abb953a0b82e17d098
BLAKE2b-256 checksum
How to use checksums
b5bf12d3290a5607db3b22f5d058b8cb24ee0b3844193b883352289c4ccfb843
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.15

Release files / geomprompt-0.2.5-py3-none-any.whl

Download URL geomprompt-0.2.5-py3-none-any.whl
Size 25.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8aa2bbb7b8a52408b7b84e92c2bb9dc3375146147d3ee87ac529cc2584f28b7e
BLAKE2b-256 checksum
How to use checksums
a07f07f918286fd84f18722bc7446c6c173cc16ec03aee7fe32941cee024ded6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.15

Release history Release notifications | RSS feed

This release

0.2.5 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page