{"data":{"slug":"facebookresearch-segment-anything","name":"segment-anything","tagline":"Provides code for running inference with the SegmentAnything Model (SAM), including model checkpoints and example notebooks.","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":54877,"forks":6375,"topics":[],"archived":false,"github_pushed_at":"2024-09-18T17:46:55+00:00","maintenance_label":"Dormant","stars_delta_30d":247,"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":594,"watchers":339,"ai_summary":"This repository offers tools for using the SegmentAnything Model (SAM) for image segmentation tasks. It includes installation instructions, example notebooks, and scripts for generating masks from images.","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-09-20T04:29:25.118505+00:00","categories":[{"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"},{"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"}],"tags":[{"slug":"coco-format","name":"coco format"},{"slug":"image-segmentation","name":"image segmentation"},{"slug":"inference","name":"inference"},{"slug":"mask-generation","name":"mask generation"},{"slug":"model-checkpoints","name":"model checkpoints"},{"slug":"notebooks","name":"notebooks"},{"slug":"onnx","name":"onnx"},{"slug":"pytorch","name":"pytorch"}],"trust":{"provenance":{"is_fork":false,"github_id":618058471,"owner_type":"Organization","methodology":"github_public_v1","parent_repo":null,"near_duplicate_slugs":[]},"computed_at":"2026-09-18T08:15:33.939Z","maintenance":{"label":"Dormant","score":18,"methodology":"github_public_v1","releases_90d":0,"days_since_push":729,"last_release_at":null,"stars_delta_30d":247,"open_issues_delta_30d":-1},"security_summary":{"status":"no_lockfile","scanner":null,"low_count":0,"high_count":0,"last_scan_at":"2026-09-18T08:15:36.088Z","medium_count":0,"scan_profile":"none","critical_count":0}},"capability_facts":{"scan":{"source":"repo_scan","observed_at":"2026-09-18T08:15:32.881Z"},"languages":{"value":["jupyter notebook"],"source":"github.language","observed_at":"2026-09-18T08:15:32.881Z"},"license_spdx":{"value":"Apache-2.0","source":"github.license","observed_at":"2026-09-18T08:15:32.881Z"}},"decision_facts":{"hosting":null,"pricing":null,"requirements":{"notes":["Requires Python 3.8 or higher.","PyTorch 1.7 and torchvision 0.8 or higher are required.","CUDA support is recommended for optimal performance."],"min_ram_gb":8,"requires_docker":false},"constraints":{"min_ram_gb":8,"requires_docker":false},"when_to_use":["When you need to perform image segmentation tasks with high accuracy and flexibility, as Segment-Anything provides a robust model and detailed notebooks for prompt-based and automatic mask generation.","If you are working with complex images where manual segmentation is impractical, Segment-Anything can automate the process with its automatic mask generator feature.","When you require a tool that supports both prompt-based and automatic mask generation, allowing for a versatile approach to segmentation tasks."],"when_not_to_use":["If your project strictly requires real-time segmentation, as Segment-Anything, while efficient, may not meet the latency requirements of real-time applications.","When you are working in a resource-constrained environment, as Segment-Anything requires a significant amount of computational resources, including CUDA support for optimal performance.","If your project does not require the flexibility of prompt-based segmentation and you are looking for a simpler, more streamlined tool for basic segmentation tasks."],"source":"enrich:decision_facts","observed_at":"2026-09-18T09:51:17.685Z"},"constraint_facets":{"min_ram_gb":8,"requires_docker":false},"decision_summary":[{"label":"Requirements","value":"Min 8 GB RAM; Requires Python 3.8 or higher.; PyTorch 1.7 and torchvision 0.8 or higher are required.; CUDA support is recommended for optimal performance."},{"label":"Adopt for","value":"Segment-Anything is a tool for image segmentation tasks, offering model checkpoints and example notebooks for generating masks from images."}]}}