Assumptions: Complete the guide to stream wirelessly to your desktop or laptop: Setup guide
Launch or make sure wireless stream is running. See guide: Setup guide. We set the resolution to 720p (1280x720) and 30 FPS. On RTX3090 FastSAM is not able to run 30 FPS (only 15-16 FPS), which means frames are skipped to provide you with the latest frame at all times.
Clone FastSAM fork:
git clone https://github.com/MayFly-AI/FastSAM.git
Run the demo (it automatically downloads the weights into the ./weights folder):
python Inference_sensorleap.py --model_path ./weights/FastSAM-x.pt --imgsz 640
The above command segments anything in real-time. If you wish to supply a text prompt to segment a specific object of interest, use
python Inference_sensorleap.py --model_path ./weights/FastSAM-x.pt --imgsz 640 --text_prompt "the white chair"
Note that when using text prompting, the FPS drops to less than 1, since OpenAI's CLIP network is called which is computationally expensive. Also note that the accuracy of text prompting is not good enough for any real applications.
It is also possible to use box prompt which given a bounding box (xywh) outputs the segmentation of the object inside it or to use a point prompt which given a pixel coordinate outputs the segmentation of the object you point at.
Optional If you have an iRobot Create3 and wish to drive around while running FastSAM live, follow this guide Drive iRobot Create3
We forked the official FastSAM repo to have a timestamp of the code with our few additions. The fork is located at
https://github.com/MayFly-AI/FastSAM