arcadelab / FastSAM3D

Code for "FastSAM3D: An Efficient Segment Anything Model for 3D Volumetric Medical Images"
https://arxiv.org/abs/2403.09827
Apache License 2.0
64 stars 3 forks source link

Code for segmenting a single image #5

Open AlexanderZeilmann opened 1 month ago

AlexanderZeilmann commented 1 month ago

With the original segment anything all I have to do to segment a single image is downloading the checkpoint and running

from segment_anything import SamPredictor, sam_model_registry
sam = sam_model_registry["<model_type>"](checkpoint="<path/to/checkpoint>")
predictor = SamPredictor(sam)
predictor.set_image(<your_image>)
masks, _, _ = predictor.predict(<input_prompts>)

How can I do something similar in FastSAM3D? I downloaded the FastSAM3D checkpoint and have a 3D image with prompts ready. How do use FastSAM3D to segment my image using my prompts?

skill-diver commented 2 weeks ago

You could use infer.sh, and modify the parameter as you want. vp means visualization path you want to output, tdp mean the image you want to used for segmenting.

python validation.py --seed 2023 \ -vp ./results/vis_sam_med3d \ -tdp data/initial_test_dataset/total_segment -nc 1