Skip to content

ian-coccimiglio/SAMLab

Repository files navigation

SAMLab

Herein are notebooks and functions for generating label images from predictions created after predicting from the Segment Anything Model provided through ultralytics. The notebook "SAM_To_Label_Images.ipynb" demonstrates how this works.

Usage

First, install ultralytics into a conda environment or with pip.

For example, to initialize and activate a new conda environment, as well as install the relevant packages conda create --name ultralytics-env python=3.8 -y

conda activate ultralytics-env

conda install -c pytorch -c nvidia -c conda-forge pytorch torchvision pytorch-cuda=11.8 ultralytics

The function "make_label_image.py" inputs the masks generated by ultralytics and generates a label image from it. These are easier to interoperate with, and are not (currently) directly exportable from ultralytics.

Original Image Mask Image

So far, I've tested this on 2-dimensional RGB PNG and TIF images.

I hope this helps you with segmenting your images!

About

Generating label images from SAM predictions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published