{"data":{"slug":"facebookresearch-segment-anything","name":"segment-anything","tagline":"Repository providing code for running inference with the SegmentAnything Model (SAM)","github_url":"https://github.com/facebookresearch/segment-anything","owner":"facebookresearch","repo":"segment-anything","owner_avatar_url":"https://avatars.githubusercontent.com/u/16943930?v=4","primary_language":"Jupyter Notebook","stars":54520,"forks":6354,"topics":[],"archived":false,"github_pushed_at":"2024-09-18T17:46:55+00:00","maintenance_label":"Dormant","url":"https://www.graphcanon.com/tools/facebookresearch-segment-anything","markdown_url":"https://www.graphcanon.com/tools/facebookresearch-segment-anything.md","api_url":"https://www.graphcanon.com/api/graphcanon/tools/facebookresearch-segment-anything","graph_url":"https://www.graphcanon.com/api/graphcanon/graph?tool=facebookresearch-segment-anything","description":"The repository provides code for running inference with the SegmentAnything Model (SAM), links for downloading the trained model checkpoints, and example notebooks that show how to use the model.","homepage_url":null,"license":"Apache-2.0","open_issues":595,"watchers":333,"ai_summary":"Provides tools and models focused on segmenting anything in images, including example notebooks to show how to use the model.","readme_excerpt":"## Installation\n\nThe code requires `python>=3.8`, as well as `pytorch>=1.7` and `torchvision>=0.8`. Please follow the instructions [here](https://pytorch.org/get-started/locally/) to install both PyTorch and TorchVision dependencies. Installing both PyTorch and TorchVision with CUDA support is strongly recommended.\n\nInstall Segment Anything:\n\n```\npip install git+https://github.com/facebookresearch/segment-anything.git\n```\n\nor clone the repository locally and install with\n\n```\ngit clone git@github.com:facebookresearch/segment-anything.git\ncd segment-anything; pip install -e .\n```\n\nThe following optional dependencies are necessary for mask post-processing, saving masks in COCO format, the example notebooks, and exporting the model in ONNX format. `jupyter` is also required to run the example notebooks.\n\n```\npip install opencv-python pycocotools matplotlib onnxruntime onnx\n```\n\n---\n\n## <a name=\"GettingStarted\"></a>Getting Started\n\nFirst download a [model checkpoint](#model-checkpoints). Then the model can be used in just a few lines to get masks from a given prompt:\n\n```\nfrom segment_anything import SamPredictor, sam_model_registry\nsam = sam_model_registry[\"<model_type>\"](checkpoint=\"<path/to/checkpoint>\")\npredictor = SamPredictor(sam)\npredictor.set_image(<your_image>)\nmasks, _, _ = predictor.predict(<input_prompts>)\n```\n\nor generate masks for an entire image:\n\n```\nfrom segment_anything import SamAutomaticMaskGenerator, sam_model_registry\nsam = sam_model_registry[\"<model_type>\"](checkpoint=\"<path/to/checkpoint>\")\nmask_generator = SamAutomaticMaskGenerator(sam)\nmasks = mask_generator.generate(<your_image>)\n```\n\nAdditionally, masks can be generated for images from the command line:\n\n```\npython scripts/amg.py --checkpoint <path/to/checkpoint> --model-type <model_type> --input <image_or_folder> --output <path/to/output>\n```\n\nSee 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.\n\n<p float=\"left\">\n  <img src=\"assets/notebook1.png?raw=true\" width=\"49.1%\" />\n  <img src=\"assets/notebook2.png?raw=true\" width=\"48.9%\" />\n</p>\n\n---\n\n## License\n\nThe model is licensed under the [Apache 2.0 license](LICENSE).","github_created_at":"2023-03-23T17:03:03+00:00","created_at":"2026-07-11T23:09:22.107929+00:00","updated_at":"2026-07-12T01:15:07.230533+00:00","categories":[{"slug":"model-training","name":"Model Training","url":"https://www.graphcanon.com/categories/model-training","markdown_url":"https://www.graphcanon.com/categories/model-training.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/model-training"},{"slug":"inference-serving","name":"Inference & Serving","url":"https://www.graphcanon.com/categories/inference-serving","markdown_url":"https://www.graphcanon.com/categories/inference-serving.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/inference-serving"}],"tags":[{"slug":"image-processing","name":"image processing"},{"slug":"notebooks","name":"notebooks"},{"slug":"segmentation","name":"segmentation"},{"slug":"inference","name":"inference"}],"trust":{"provenance":{"is_fork":false,"github_id":618058471,"owner_type":"Organization","methodology":"github_public_v1","parent_repo":null,"near_duplicate_slugs":[]},"computed_at":"2026-07-11T23:09:27.473Z","maintenance":{"label":"Dormant","score":18,"methodology":"github_public_v1","releases_90d":0,"days_since_push":661,"last_release_at":null},"security_summary":{"status":"no_lockfile","scanner":null,"low_count":0,"high_count":0,"last_scan_at":"2026-07-11T23:09:27.907Z","medium_count":0,"scan_profile":"none","critical_count":0}},"capability_facts":{"scan":{"source":"repo_scan","observed_at":"2026-07-12T01:15:07.170Z"},"languages":{"value":["jupyter notebook"],"source":"github.language","observed_at":"2026-07-12T01:15:07.170Z"},"license_spdx":{"value":"Apache-2.0","source":"github.license","observed_at":"2026-07-12T01:15:07.170Z"}}}}