고속 Segment Anything 모델(FastSAM)

고속 세그먼트 애니씽 모델(FastSAM)은 세그먼트 애니씽 작업을 위한 실시간 CNN 기반 솔루션입니다. 이 작업은 다양한 사용자 인터랙션 프롬프트를 바탕으로 이미지 내 모든 객체를 분할하도록 설계되었습니다. FastSAM은 경쟁력 있는 성능을 유지하면서 연산 부담을 크게 줄여 다양한 비전 작업에 실용적인 선택지를 제공합니다.



시청: Ultralytics에서 FastSAM을 사용한 객체 추적

모델 아키텍처#

고속 Segment Anything 모델(FastSAM) 아키텍처 개요

개요#

FastSAM은 상당한 연산 리소스를 요구하는 대형 Transformer 모델인 세그먼트 애니씽 모델(SAM)의 한계를 해결하도록 설계되었습니다. FastSAM은 세그먼트 애니씽 작업을 전체 인스턴스 분할과 프롬프트 기반 선택의 두 단계로 나눕니다. 첫 번째 단계에서는 YOLOv8-seg를 사용해 이미지의 모든 인스턴스에 대한 분할 마스크를 생성합니다. 두 번째 단계에서는 프롬프트에 해당하는 관심 영역을 출력합니다.

주요 기능#

  1. 실시간 솔루션: FastSAM은 CNN의 연산 효율성을 활용해 세그먼트 애니씽 작업에 실시간 솔루션을 제공하므로, 빠른 결과가 필요한 산업 애플리케이션에 유용합니다.

  2. 효율성과 성능: FastSAM은 SAM과 비슷한 성능을 달성하면서 연산 및 리소스 요구량을 크게 줄여 실시간 애플리케이션을 지원합니다.

  3. 프롬프트 기반 분할: FastSAM은 다양한 사용자 인터랙션 프롬프트를 바탕으로 이미지 내 모든 객체를 분할하여 여러 상황에서 유연성과 적응성을 제공합니다.

  4. YOLOv8-seg 기반: FastSAM은 인스턴스 분할 브랜치가 탑재된 객체 검출기인 YOLOv8-seg를 기반으로 합니다. 따라서 이미지 내 모든 인스턴스의 분할 마스크를 효과적으로 생성할 수 있습니다.

  5. 벤치마크에서의 경쟁력 있는 결과: MS COCO의 객체 제안 작업에서 FastSAM은 단일 NVIDIA RTX 3090에서 SAM보다 훨씬 빠른 속도로 높은 점수를 달성하여 효율성과 성능을 입증했습니다.

  6. 실용적인 애플리케이션: 이 접근 방식은 다양한 비전 작업에 실용적인 솔루션을 제공하며, 이전 세그먼트 애니씽 방법보다 수십 배에서 수백 배 빠르게 작동합니다.

  7. 모델 압축의 실현 가능성: FastSAM은 구조에 인공적 사전 정보를 도입하여 계산량을 크게 줄이는 경로의 실현 가능성을 보여 줍니다. 이를 통해 일반 비전 작업을 위한 대규모 모델 아키텍처의 새로운 가능성을 열어 줍니다.

사용 가능한 모델, 지원 작업 및 작동 모드#

이 표에는 사용 가능한 모델, 각 모델의 사전 학습된 가중치, 지원 작업 및 학습, 검증, 추론, 내보내기와 같은 다양한 작동 모드와의 호환성이 나와 있습니다. 지원되는 모드는 ✅로, 지원되지 않는 모드는 ❌로 표시됩니다.

모델 유형사전 학습 가중치지원 작업학습검증추론내보내기
FastSAM-sFastSAM-s.pt인스턴스 분할❌✅✅✅
FastSAM-xFastSAM-x.pt인스턴스 분할❌✅✅✅

FastSAM과 YOLO 비교#

여기에서는 FastSAM-s를 Meta의 SAM 변형 모델 및 YOLO26을 포함한 Ultralytics 분할 모델과 비교합니다:

모델크기
(MB)
매개변수
(M)
속도(CPU)
(ms/im)
Meta SAM-b37593.741703
Meta SAM2-b16280.828867
Meta SAM2-t78.138.923430
MobileSAM40.710.123802
YOLOv8 백본을 사용하는 FastSAM-s23.911.858.0
Ultralytics YOLOv8n-seg7.1 (11.0배 더 작음)3.4 (11.4배 더 적음)24.8 (945배 더 빠름)
Ultralytics YOLO11n-seg6.2 (12.6배 더 작음)2.9 (13.4배 더 적음)24.3 (964배 더 빠름)
Ultralytics YOLO26n-seg6.7 (11.7배 더 작음)2.7 (14.4배 더 적음)25.2 (930배 더 빠름)

이 비교는 SAM 변형 모델과 YOLO 세그멘테이션 모델 간 모델 크기와 속도의 상당한 차이를 보여줍니다. SAM은 고유한 자동 세그멘테이션 기능을 제공하지만, 특히 YOLOv8n-seg, YOLO11n-seg, YOLO26n-seg와 같은 YOLO 모델은 크기가 훨씬 작고 속도가 빠르며 연산 효율성이 더 높습니다.

SAM 속도는 PyTorch로 측정했으며, YOLO 속도는 ONNX Runtime으로 측정했습니다. 테스트는 16GB RAM을 탑재한 2025년형 Apple M4 Air에서 torch==2.10.0, ultralytics==8.4.31, onnxruntime==1.24.4를 사용해 실행했습니다. 이 테스트를 재현하려면 다음을 수행합니다:

예제
from ultralytics import ASSETS, SAM, YOLO, FastSAM

# SAM2-t, SAM2-b, SAM-b, MobileSAM 프로파일링
for file in ["sam_b.pt", "sam2_b.pt", "sam2_t.pt", "mobile_sam.pt"]:
    model = SAM(file)
    model.info()
    model(ASSETS)

# FastSAM-s 프로파일링
model = FastSAM("FastSAM-s.pt")
model.info()
model(ASSETS)

# YOLO 모델 프로파일링(ONNX)
for file_name in ["yolov8n-seg.pt", "yolo11n-seg.pt", "yolo26n-seg.pt"]:
    model = YOLO(file_name)
    model.info()
    onnx_path = model.export(format="onnx", dynamic=True, nms=False)  # YOLO26 NMS 없는 헤드; YOLOv8/YOLO11에서는 작동하지 않음
    model = YOLO(onnx_path)
    model(ASSETS)

사용 예시#

FastSAM 모델은 Python 애플리케이션에 쉽게 통합할 수 있습니다. Ultralytics는 Python API와 CLI 명령을 모두 제공합니다.

예측 사용법#

이미지를 세그먼트화하려면 아래와 같이 predict 메서드를 사용하세요:

예제
from ultralytics import FastSAM

# 추론 소스를 정의합니다
source = "path/to/bus.jpg"

# FastSAM 모델을 생성합니다
model = FastSAM("FastSAM-s.pt")  # 또는 FastSAM-x.pt

# 이미지에서 추론 실행
everything_results = model(source, device="cpu", retina_masks=True, imgsz=1024, conf=0.4, iou=0.9)

# bboxes 프롬프트로 추론 실행
results = model(source, bboxes=[439, 437, 524, 709])

# 포인트 프롬프트로 추론을 실행합니다
results = model(source, points=[[200, 200]], labels=[1])

# 텍스트 프롬프트로 추론을 실행합니다
results = model(source, texts="a photo of a dog")

# 바운딩 박스, 포인트, 텍스트 프롬프트를 동시에 사용해 추론을 실행합니다
results = model(source, bboxes=[439, 437, 524, 709], points=[[200, 200]], labels=[1], texts="a photo of a dog")

이 코드 조각은 사전 학습 모델을 간편하게 불러오고 이미지에서 예측을 실행하는 방법을 보여 줍니다.

FastSAMPredictor 예제

이미지에서 한 번 추론을 실행해 모든 분할 results을 얻은 다음, 추론을 다시 실행하지 않고 해당 결과에 여러 프롬프트를 적용할 수 있습니다.

from ultralytics.models.fastsam import FastSAMPredictor

# FastSAMPredictor를 생성합니다
overrides = {"conf": 0.25, "task": "segment", "mode": "predict", "model": "FastSAM-s.pt", "save": False, "imgsz": 1024}
predictor = FastSAMPredictor(overrides=overrides)

# 모든 항목을 세그먼트화합니다
everything_results = predictor("ultralytics/assets/bus.jpg")

# 프롬프트 추론
bbox_results = predictor.prompt(everything_results, bboxes=[[200, 200, 300, 300]])
point_results = predictor.prompt(everything_results, points=[200, 200])
text_results = predictor.prompt(everything_results, texts="a photo of a dog")
참고

위 예시에서 반환된 모든 results은 예측된 마스크와 원본 이미지에 액세스할 수 있는 Results 객체입니다.

검증 사용법#

FastSAM은 단일 객체 클래스의 검출 및 분할만 지원하므로 모든 객체를 동일한 클래스로 인식하고 분할합니다. 데이터셋을 준비할 때 모든 객체 범주 ID를 0으로 변환하세요.

데이터셋에서 모델을 다음과 같이 검증할 수 있습니다:

예제
from ultralytics import FastSAM

# FastSAM 모델을 생성합니다
model = FastSAM("FastSAM-s.pt")  # 또는 FastSAM-x.pt

# 모델을 검증합니다
results = model.val(data="coco8-seg.yaml")

추적 사용법#

이미지에서 객체 추적을 수행하려면 아래와 같이 track 메서드를 사용합니다:

예제
from ultralytics import FastSAM

# FastSAM 모델을 생성합니다
model = FastSAM("FastSAM-s.pt")  # 또는 FastSAM-x.pt

# 비디오에서 FastSAM 모델로 추적
results = model.track(source="path/to/video.mp4", imgsz=640)

FastSAM 공식 사용법#

FastSAM은 CASIA-LMC-Lab/FastSAM 리포지토리에서도 바로 사용할 수 있습니다. FastSAM을 사용하는 일반적인 단계는 다음과 같습니다:

설치#

  1. FastSAM 리포지토리를 복제합니다:

    git clone https://github.com/CASIA-LMC-Lab/FastSAM.git
  2. Python 3.9를 사용하는 Conda 환경을 만들고 활성화합니다:

    conda create -n FastSAM python=3.9
    conda activate FastSAM
  3. 복제한 리포지토리로 이동한 다음 필수 패키지를 설치합니다:

    cd FastSAM
    pip install -r requirements.txt
  4. CLIP 모델을 설치합니다:

    pip install git+https://github.com/ultralytics/CLIP.git

사용 예시#

  1. 모델 체크포인트를 다운로드합니다.

  2. 추론에 FastSAM을 사용합니다. 명령어 예시는 다음과 같습니다:

    • 이미지의 모든 항목을 분할합니다:

      python Inference.py --model_path ./weights/FastSAM.pt --img_path ./images/dogs.jpg
    • 텍스트 프롬프트를 사용하여 특정 객체를 분할합니다:

      python Inference.py --model_path ./weights/FastSAM.pt --img_path ./images/dogs.jpg --text_prompt "the yellow dog"
    • 바운딩 박스 내의 객체를 분할합니다(xywh 형식으로 박스 좌표를 입력합니다):

      python Inference.py --model_path ./weights/FastSAM.pt --img_path ./images/dogs.jpg --box_prompt "[570,200,230,400]"
    • 특정 지점 주변의 객체를 분할합니다:

      python Inference.py --model_path ./weights/FastSAM.pt --img_path ./images/dogs.jpg --point_prompt "[[520,360],[620,300]]" --point_label "[1,0]"

또한 CASIA-LMC-Lab의 Colab 데모를 통해 FastSAM을 사용해 볼 수 있습니다.

인용 및 감사의 글#

실시간 인스턴스 분할 분야에 크게 기여한 FastSAM 저자들에게 감사의 뜻을 전합니다:

인용
@misc{zhao2023fast,
      title={Fast Segment Anything},
      author={Xu Zhao and Wenchao Ding and Yongqi An and Yinglong Du and Tao Yu and Min Li and Ming Tang and Jinqiao Wang},
      year={2023},
      eprint={2306.12156},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

FastSAM 원본 논문은 arXiv에서 확인할 수 있습니다. 저자들은 연구 내용을 공개했으며, 코드베이스는 GitHub에서 확인할 수 있습니다. 해당 분야를 발전시키고 더 넓은 커뮤니티가 연구 내용을 이용할 수 있도록 한 저자들의 노력에 감사드립니다.

자주 묻는 질문#

  • 고속 세그먼트 애니씽 모델을 뜻하는 FastSAM은 객체 분할 작업에서 높은 성능을 유지하면서 연산 부담을 줄이도록 설계된 실시간 합성곱 신경망(CNN) 기반 솔루션입니다. 더 무거운 Transformer 기반 아키텍처를 사용하는 세그먼트 애니씽 모델(SAM)과 달리, FastSAM은 효율적인 인스턴스 분할을 위해 Ultralytics YOLOv8-seg를 사용하며, 전체 인스턴스 분할 후 프롬프트 기반 선택의 두 단계로 작업을 수행합니다.

  • FastSAM은 YOLOv8-seg를 사용한 전체 인스턴스 분할과 프롬프트 기반 선택의 두 단계로 분할 작업을 분리하여 실시간 분할을 구현합니다. FastSAM은 CNN의 연산 효율성을 활용해 경쟁력 있는 성능을 유지하면서 연산 및 리소스 요구량을 크게 줄입니다. 이러한 2단계 접근 방식으로 빠른 결과가 필요한 애플리케이션에 적합한 빠르고 효율적인 분할을 제공합니다.

  • FastSAM은 실시간 분할 성능이 필요한 다양한 컴퓨터 비전 작업에 실용적입니다. 적용 분야는 다음과 같습니다:

    • 품질 관리 및 보증을 위한 산업 자동화
    • 보안 및 감시를 위한 실시간 비디오 분석
    • 객체 탐지 및 분할을 위한 자율주행차
    • 정밀하고 신속한 분할 작업을 위한 의료 영상

    다양한 사용자 상호작용 프롬프트를 처리할 수 있어 FastSAM은 여러 시나리오에 유연하게 적용할 수 있습니다.

  • Python에서 추론에 FastSAM을 사용하려면 다음 예제를 참고하세요:

    from ultralytics import FastSAM
    
    # 추론 소스를 정의합니다
    source = "path/to/bus.jpg"
    
    # FastSAM 모델을 생성합니다
    model = FastSAM("FastSAM-s.pt")  # 또는 FastSAM-x.pt
    
    # 이미지에서 추론 실행
    everything_results = model(source, device="cpu", retina_masks=True, imgsz=1024, conf=0.4, iou=0.9)
    
    # bboxes 프롬프트로 추론 실행
    results = model(source, bboxes=[439, 437, 524, 709])
    
    # 포인트 프롬프트로 추론을 실행합니다
    results = model(source, points=[[200, 200]], labels=[1])
    
    # 텍스트 프롬프트로 추론을 실행합니다
    results = model(source, texts="a photo of a dog")
    
    # 바운딩 박스, 포인트, 텍스트 프롬프트를 동시에 사용해 추론을 실행합니다
    results = model(source, bboxes=[439, 437, 524, 709], points=[[200, 200]], labels=[1], texts="a photo of a dog")

    추론 방법에 대한 자세한 내용은 문서의 예측 사용법 섹션을 참조하세요.

  • FastSAM은 분할 작업을 안내하기 위해 여러 유형의 프롬프트를 지원합니다:

    • 전체 프롬프트: 보이는 모든 객체를 분할합니다.
    • 바운딩 박스 (BBox) 프롬프트: 지정된 바운딩 박스 내의 객체를 분할합니다. 감지된 마스크와 겹치지 않는 박스는 아무것도 선택하지 않습니다.
    • 텍스트 프롬프트: 설명과 일치하는 객체를 텍스트 설명을 사용해 분할합니다.
    • 포인트 프롬프트: 사용자가 지정한 특정 지점 주변의 객체를 분할합니다.

    이러한 유연성 덕분에 FastSAM은 다양한 사용자 상호작용 시나리오에 대응하여 여러 애플리케이션에서 유용하게 활용할 수 있습니다. 이러한 프롬프트 사용에 대한 자세한 내용은 주요 기능 섹션을 참조하세요.

댓글26

질문을 하거나 결과를 공유하거나 다른 사람을 도와주세요.

    1. PrashantDixit0GitHub(수정됨)

      @qinfendekaizhou, can you share the reproducible code for it? Or the reference from where u noticed this.

      In general, post-process time gets increased because of the post-processes involved to show the results, like

      1. NMS
      2. filtering by confidence score/ labels
      3. Scaling results to the original given inputs
      4. Number of objects to be annotated,
      5. Type of annotation, like BB or Segmentation
  1. shahedmomenzadehGitHub

    Hi, I have a question Can I use the generated bbox cordinates by a yolo detection model like yolov11 as bboxes prompt for FastSAM ?

    1. Glenn JocherUltralytics

      @shahedmomenzadeh yes, you can use YOLO detection model-generated bbox coordinates as prompts for FastSAM. The FastSAM documentation shows examples of passing bbox coordinates directly to the model using either the Python API or CLI. Just ensure your coordinates are in XYXY format as shown in the examples.

  2. ismailwaleGitHub

    How can I make an inference of a video using frame by frame in loop using FastSam ?because I tried multiple times making inference directly with video predictor I constantly running out of memory despite setting stream =True since SAM is trying to keep the memory of 2000 frames of the video at ones . I will appreciate any ideal on how to predict and segment the video as a single frame image at every instance and put everything in a loop.

    Similar question win MobileSam

    1. Glenn JocherUltralytics

      @ismailwale to process a video frame by frame and avoid memory overload with FastSAM or MobileSAM, load the video as a frame sequence using a tool like OpenCV. Loop through each frame, run inference on it individually, and clear any cached results to free up memory between frames. For reference on frame-wise usage, consult OpenCV and FastSAM integration. Let me know if you need further clarifications!

    2. llu025GitHub

      Thank you all for your great work! I am having troubles with prompting with a bounding box, it seems the FastSAM model ignores it and detects objects all over the video frames. This is how I obtain the results:

      results = model(
          input_filename,
          device=device,
          imgsz=(736, 1280),
          verbose=False,
          stream=True,
          bboxes=[0, 0, 360, 640],
          retina_masks=True,
          conf=0.4,
          iou=0.9,
      )

      I also tried with bboxes=[[0, 0, 360, 640]], without success. The model should detect objects in the top left quadrant of the video, instead it detects everywhere. Also, it oddly does not raise any error or warnings, both with bboxes as list of integers or bboxes as list of lists of integers.

    3. Glenn JocherUltralytics

      It seems the bounding box prompts aren't being applied as expected. Ensure the bboxes format is correct (e.g., [[x1, y1, x2, y2]] as a list of lists). Additionally, try using the FastSAMPredictor approach for more controlled prompt application, as shown in this example. Let me know if the issue persists!

    4. llu025GitHub

      Thank you @glenn-jocher for the "prompt" response ;-)

      I need to use stream=True since I am working with large videos. I cannot use it coupled with FastSAMPredictor, because it does not support it. My only alternative is to grab frames on my own with OpenCV, is that correct?

      By the way, in your examples in here bboxes is passed as a list of integers, I followed those in the beginning. I see in the examples with FastSAMPredictor that a list of lists is used instead. In any case, I ensured that I was using a list of lists, and it did not work anyway.

      Here's a minimal example of what I am trying to do, i.e., detecting objects in the top left part of the video:

      from ultralytics import FastSAM
      import os
      import ffmpeg
      
      input_filename = "test_video.mp4"
      base_name = os.path.splitext(os.path.basename(input_filename))[0]
      output_filename = os.path.join("output", f"{base_name}.avi")
      
      model = FastSAM("models/FastSAM-x.pt")
      
      process2 = (
          ffmpeg.input(
              "pipe:",
              format="rawvideo",
              pix_fmt="rgb24",
              s="1280x720",
              loglevel="-8",
          )
          .output(
              output_filename,
              pix_fmt="yuv420p",
              vcodec="libx264",
              loglevel="-8",
              crf=17,
          )
          .overwrite_output()
          .run_async(pipe_stdin=True)
      )
      
      results = model(
          input_filename,
          device="cuda",
          imgsz=(736, 1280),
          verbose=False,
          stream=True,
          bboxes=[[0, 0, 360, 640]],
          retina_masks=True,
          conf=0.4,
          iou=0.9,
      )
      
      for result in results:
          frame = result.plot()
          # Save on disk with process2
          process2.stdin.write(frame.tobytes())
      
      process2.stdin.close()
      process2.wait()
    5. Glenn JocherUltralytics

      Thank you for the detailed explanation and example. Yes, you're correct—using OpenCV to manually grab frames is a valid and efficient approach, especially when working with stream=True for large videos, as it avoids memory issues. Regarding bboxes, FastSAM expects a list of lists in the format [[x1, y1, x2, y2]]. If this still doesn't work as intended, please ensure your bounding box coordinates are correct and within the frame dimensions. Let us know if you encounter any further issues!

    6. llu025GitHub

      I still encounter the same issue. I used bboxes=[[20, 20, 500, 500]] just to be 100% sure the coordinates are within the the frame dimensions (1280x720), nothing changed. Since I have to grab frames with OpenCV anyway, I will just crop them myself, but I am quite sure this option is not working as intended.

    7. Glenn JocherUltralytics

      @llu025 thank you for the update. If you’re certain the bboxes parameter is properly configured and still not working as intended, cropping frames manually with OpenCV before passing them to the model is indeed a reliable workaround. It may also be worth checking the latest FastSAM updates or reporting this as a potential issue to ensure the bounding box prompt functionality is reviewed. Let us know if you need further assistance!

  3. chongkuiqiGitHub

    Thanks for your great work! I'm using FastSAM-x with bboxes prompt, the original image shape is [720, 1280], and I set 'imgsz' 1024. However, the results mask shape is [576, 1024], but I remembered in ultralytics-8.2.10, I can get masks with the same shape as the original image. May I ask why this change happened ?

    1. Glenn JocherUltralytics

      @feiwenxiong fastSAM should support multiple boxes. If you're experiencing limitations, please ensure your input format is correct. For further assistance, you might want to check the latest updates or documentation.

  4. YuechengLiuGitHub

    Thanks the authors for the great work!

    I'm using FastSAM-x for instance segmentation (bboxes as the prompt), but I find that the shape of the predicted masks mismatch with the bounding box number. (e.g. the model takes 18 bboxes as input, but the shape of the predicted mask is (17, H, W)) . I tried to set conf=0.01 and iou=0.999, but it doesn't work. How can I solve that? Thanks!

    1. Glenn JocherUltralytics

      @YuechengLiu thank you for your kind words! The issue you're experiencing might be due to a mismatch in the bounding box prompts and the segmentation results. Please ensure you're using the latest version of the FastSAM model. If the problem persists, consider checking the input format and the bounding box coordinates. For further assistance, you can refer to the FastSAM documentation: https://docs.ultralytics.com/models/fast-sam/.

    2. YuechengLiuGitHub

      Thanks for your kind reply! The bounding boxes I'm using are predicted by yolov10x (result.boxes.xyxy), so I think the input format might be right. I also tried the same bounding boxes for mobile_sam, and the output dimension is as expected (same as the input dimension). The problem does not always occur. Do you have any idea about that? Thanks!

    3. Glenn JocherUltralytics

      Thanks for confirming you're using the latest version. Given that the issue is intermittent, it might be related to the specific bounding boxes or the image content. Please try running the model with a different set of bounding boxes or images to see if the issue persists. If it does, consider opening an issue on the GitHub repository with detailed information for further investigation.

  5. nguyenvandang1998GitHub

    Hi! I am using the FastSAM model and trying to obtain information about the bounding box and mask image of the object, but I don't know how to do it. I hope you can help me. Thank you very much!!

    1. Glenn JocherUltralytics(수정됨)

      Hi there! 🙌 To extract both bounding boxes and mask images using the FastSAM model, you would typically work with the results object returned by the model's prediction method. For the bounding boxes, you can access them directly as shown in the documentation or examples provided. For the mask images, since FastSAM is designed for real-time segmentation, the results should also include segmentation masks corresponding to detected objects.

      Here's a simplified way to access both:

      from ultralytics import FastSAM
      
      # Define your image source
      source = 'path/to/your/image.jpg'
      
      # Load the FastSAM model (ensure you've chosen the correct model path)
      model = FastSAM('FastSAM-s.pt')  # or another appropriate model
      
      # Perform inference
      results = model(source)
      
      # Accessing bounding boxes (assuming XYXY format)
      boxes = results[0].boxes.xyxy
      
      # Accessing segmentation masks
      # The masks are directly associated with detected objects in the results
      masks = results[0].masks
      
      # To visualize or further process masks and boxes, you would iterate through these objects

      To visualize or save the masks, you'd typically iterate over the masks object, and each mask can be processed according to your requirements (e.g., overlaying on the original image or saving as separate mask images).

      Remember, the exact attribute names (boxes, masks) and methods might vary based on the model output specification, so it's always good to refer to the specific documentation or example codes for guidance.

      Hope this helps! Let us know if you have more questions. 😊

      2