So, what exactly is FastSAM? The Ultimate Guide.

Mahimai Raja J
3 min readJul 7, 2023

An YOLOv8 version of Segment Anything Model

FastSAM vs SAM from FastSAM repository

Hey, Fam in this blog I would like to talk about the FastSAM, which is one of my favourite paper in CVPR 2023.

Meta Research stunned the computer vision community in April 2023 with the publication of the Segment Anything Model (SAM), a sophisticated zero-shot picture segmentation model. This model has great segmentation capabilities: given a photo, SAM can build masks that segment items in the image with high precision. SAM was trained using the SA-1B dataset, which contained approximately 11 billion segmentation masks.

In this guide, I’ll go over what FastSAM is, why the model is valuable, and what we can learn about segmentation from it.

Let’s get started without more delay!

What is FastSAM?

FastSAM, developed by the Chinese Academy of Sciences Image and Video Analysis Group, is an image segmentation model trained on 2% of the data used to train the revolutionary Segment Anything Model (SAM). FastSAM has lower computational requirements than SAM while maintaining high accuracy.

Instance segmentation results from FastSAM repository.

Ultralytics YOLOv8 instance segmentation architecture was used to train FastSAM. This is intriguing because it demonstrates the power of the dataset on which the original SAM was trained: researchers were able to develop a model that separates objects in photos with relatively exact boundaries using only a piece of the dataset.

FastSAM employs a two-stage procedure:

  1. The segmentation masks are then generated by a pre-trained YOLOv8 instance segmentation model.
  2. A text prompt can be supplied as an option to return masks linked to the prompt. CLIP is used for this. CLIP is applied on each mask, and photos that have a high similarity to the text prompt are returned as a match.

The FastSAM paper point out that the model may also be utilised for zero-shot edge detection and object proposal creation.Furthermore, the authors of FastSAM claim a 50x quicker run-time speed, making the model more practical to run than the original SAM model.

Feel free to play with 🏃 Fast Segment Anything 🤗

Prompt-guided Segmentation

segmentation using prompt from FastSAM repository.

FastSAM can segment any object inside an image using numerous user interaction text prompts, giving it flexibility and adaptability in a variety of settings. This lead to the auto labelling feature. (Will talk about this in upcoming blogs)

Use Cases

One of the most important feature from FastSAM is that a small, real-time model may replicate an output similar to SAM. FastSAM also highlights the strength of the dataset used to train SAM: with only a part of the dataset, FastSAM was able to build relatively exact masks.

Given the model’s outstanding performance, FastSAM could be utilised as a transfer-learning checkpoint for training YOLOv8 models. FastSAM could be given text prompts to generate masks for your specific activity.

Having said that, FastSAM is not a replacement for SAM. While FastSAM outperforms SAM because to the smaller dataset on which FastSAM was trained, SAM is capable of providing more exact segmentation masks.

NOTE : Choosing SAM or FastSAM depends upon the project requirements!

Conclusion

FastSAM is an image segmentation model trained on a portion of the dataset on which Meta Research’s SAM model was trained. Inference on FastSAM, as the name suggests, is faster than that of the SAM model. FastSAM could be used as a transfer-learning checkpoint, and demonstrates the quality of the SAM dataset. With that said, masks from FastSAM are less precise than masks generated by SAM.

Feel free to comment you projects built out of FastSAM!

--

--