FastSAM ONNX Weights

This repository contains ONNX-optimized weights for FastSAM (Fast Segment Anything Model), a real-time CNN-based instance segmentation model built upon the YOLOv8-Seg architecture. By converting the PyTorch weights to standard ONNX format, these models enable real-time object proposal generation and mask decoding on both CPU and GPU edge devices without requiring the PyTorch runtime.

Available Files

  • FastSAM-s.onnx: Small YOLOv8-Seg backbone variant ("s"), optimized for high frame rate and edge deployment.
  • FastSAM-x.onnx: Extra-large YOLOv8-Seg backbone variant ("x"), higher capacity proposal generation model.

How to Use

The easiest way to load and run these models is through the spatialhub Python library:

from spatialhub import FastSAM
# Initialize FastSAM segmentor
segmentor = FastSAM(model_variant="x")
# Generate mask proposals
result = segmentor.generate_masks("scene.png", conf_threshold=0.25)
# Save mask visualization
result.visualize_mask("fastsam_output.png")

Original Citation

If you use these models in academic work, please cite the original authors:

@article{zhao2023fast,
  title={Fast Segment Anything},
  author={Zhao, Xu and Ding, Wenyu and An, Jiaqi and Du, Yufan and Zhao, Tao and Lu, Mengling and Shen, Shaohua},
  journal={arXiv preprint arXiv:2306.12156},
  year={2023}
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Paper for SpatialHub/fastsam-onnx