From 7c524018a6d5f13bb8d7bfc53e166d9f81d38392 Mon Sep 17 00:00:00 2001 From: Hanzi Mao Date: Fri, 7 Apr 2023 13:10:16 -0700 Subject: [PATCH] update README: add model_type to sam registry --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 20e37c6..bdcf830 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,8 @@ First download a [model checkpoint](#model-checkpoints). Then the model can be u ``` from segment_anything import build_sam, SamPredictor -predictor = SamPredictor(build_sam(checkpoint="")) +sam = sam_model_registry[""](checkpoint="") +predictor = SamPredictor(sam) predictor.set_image() masks, _, _ = predictor.predict() ``` @@ -53,14 +54,15 @@ or generate masks for an entire image: ``` from segment_anything import build_sam, SamAutomaticMaskGenerator -mask_generator = SamAutomaticMaskGenerator(build_sam(checkpoint="")) +sam = sam_model_registry[""](checkpoint="") +mask_generator = SamAutomaticMaskGenerator(sam) masks = mask_generator.generate() ``` Additionally, masks can be generated for images from the command line: ``` -python scripts/amg.py --checkpoint --input --output +python scripts/amg.py --checkpoint --input --output ``` See the examples notebooks on [using SAM with prompts](/notebooks/predictor_example.ipynb) and [automatically generating masks](/notebooks/automatic_mask_generator_example.ipynb) for more details. @@ -85,9 +87,9 @@ See the [example notebook](https://github.com/facebookresearch/segment-anything/ Three model versions of the model are available with different backbone sizes. These models can be instantiated by running ``` from segment_anything import sam_model_registry -sam = sam_model_registry[""](checkpoint="") +sam = sam_model_registry[""](checkpoint="") ``` -Click the links below to download the checkpoint for the corresponding model name. The default model in bold can also be instantiated with `build_sam`, as in the examples in [Getting Started](#getting-started). +Click the links below to download the checkpoint for the corresponding model type. The default model in bold can also be instantiated with `build_sam`, as in the examples in [Getting Started](#getting-started). * **`default` or `vit_h`: [ViT-H SAM model.](https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth)** * `vit_l`: [ViT-L SAM model.](https://dl.fbaipublicfiles.com/segment_anything/sam_vit_l_0b3195.pth)