{"id":28147,"library":"rf-segment-anything","title":"RF Segment Anything","description":"RF Segment Anything (rf-segment-anything) provides a simple API to run Meta's Segment Anything Model (SAM) for image segmentation with just a few lines of code. Version 1.0 is currently available. Release cadence is unknown; the library appears to be in early active development.","status":"active","version":"1.0","language":"python","source_language":"en","source_url":"https://github.com/roboflow/rf-segment-anything","tags":["segment-anything","sam","image-segmentation","object-detection"],"install":[{"cmd":"pip install rf-segment-anything","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The main class is `Segmentation`, not a function named `segment`.","wrong":"from rf_segment_anything import segment","symbol":"Segmentation","correct":"from rf_segment_anything import Segmentation"},{"note":"Direct import of the package does not expose the class; you must import the class explicitly.","wrong":"import rf_segment_anything","symbol":"Segmentation","correct":"from rf_segment_anything import Segmentation"}],"quickstart":{"code":"from rf_segment_anything import Segmentation\n\nsegmenter = Segmentation()\nsegmenter.load_model(\"vit_h\")\n\n# Use an image path or numpy array\nresult = segmenter.segment(\"path/to/image.jpg\")\nprint(result)","lang":"python","description":"Instantiate a Segmentation object, load a pre-trained model (e.g., vit_h), and call segment() on an image path or numpy array."},"warnings":[{"fix":"Pre-download weights manually or set environment variable TORCH_HOME to a custom directory.","message":"Model weights are downloaded automatically on first use to ~/.cache/torch/hub/checkpoints/. Ensure you have disk space and network access.","severity":"gotcha","affected_versions":"all"},{"fix":"Access result['masks'] for the list of masks.","message":"The segment() method returns a dictionary with keys 'masks', 'boxes', etc. Do not expect a single mask array; iterate over results.","severity":"gotcha","affected_versions":"all"},{"fix":"Use the correct parameter name for your version; check documentation before upgrading.","message":"The parameter 'model_type' in load_model() may be renamed to 'model_name' in future releases.","severity":"deprecated","affected_versions":"1.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Run `pip install rf-segment-anything` in the correct Python environment.","cause":"Package not installed or installed in a different environment.","error":"ModuleNotFoundError: No module named 'rf_segment_anything'"},{"fix":"Use `from rf_segment_anything import Segmentation`.","cause":"Importing the package instead of the class.","error":"AttributeError: module 'rf_segment_anything' has no attribute 'Segmentation'"},{"fix":"Check model name (exact string) and ensure internet connection for first-time download.","cause":"Typo in model name or model not downloaded.","error":"RuntimeError: Model vit_h not found. Available: vit_b, vit_l, vit_h"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}