Skip to content

DSHydro/RiverCV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RiverCV

RiverCV is a Python library for detecting and generating river masks from imagery using foundational computer-vision models such as Segment Anything (SAM).

Features

  • Simple, high-level API for river mask generation
  • SAM predictor wrapper with point and bounding-box prompts
  • Utilities for loading images and saving masks
  • Designed to support additional foundational CV models

Installation

pip install rivercv

SAM model weights are not bundled. Download them from the SAM repository and pass the path when constructing SAMPredictor.

Quick Start

from rivercv.models import SAMPredictor
from rivercv.masks import generate_river_mask
from rivercv.utils import load_image, save_mask

# Load your image
image = load_image("path/to/river_image.jpg")

# Initialise the predictor (download weights first)
predictor = SAMPredictor(
    checkpoint="sam_vit_h_4b8939.pth",
    model_type="vit_h",
    device="cuda",  # or "cpu"
)

# Generate a river mask using a point prompt
mask = generate_river_mask(
    predictor,
    image,
    point_coords=[[512, 256]],   # click on the river
    point_labels=[1],            # 1 = foreground
)

# Save the result
save_mask(mask, "river_mask.png")

Development

git clone https://github.com/your-username/RiverCV.git
cd RiverCV
pip install -e ".[dev]"
pytest

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages