Skip to main content

GeomPrompt is the default project generated by GDA Cookiecutter. GeomPrompt contains all the boilerplate you need to create a Python package according to the best-practices of Geometric Data Analytics, Inc.

Project description

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.

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

geomprompt-0.2.5.tar.gz (50.0 kB view details)

Uploaded Source

Built Distribution

geomprompt-0.2.5-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file geomprompt-0.2.5.tar.gz.

File metadata

  • Download URL: geomprompt-0.2.5.tar.gz
  • Upload date:
  • Size: 50.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for geomprompt-0.2.5.tar.gz
Algorithm Hash digest
SHA256 3c8c893b192381b77da2c09b593ac7fc47b1c4f0b925d1abb953a0b82e17d098
MD5 d8963b6cdb26f4cbc1d75864a2f9fca8
BLAKE2b-256 b5bf12d3290a5607db3b22f5d058b8cb24ee0b3844193b883352289c4ccfb843

See more details on using hashes here.

File details

Details for the file geomprompt-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: geomprompt-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for geomprompt-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8aa2bbb7b8a52408b7b84e92c2bb9dc3375146147d3ee87ac529cc2584f28b7e
MD5 d539d12db6ad4f20393eede975590fd4
BLAKE2b-256 a07f07f918286fd84f18722bc7446c6c173cc16ec03aee7fe32941cee024ded6

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