Skip to content

QTIM-Lab/medsam_OCT_layerseg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MedSAM OCT Layer Segmentation — Inference

Fine-tuned MedSAM model for segmenting retinal layers (RNFL, GCL, IPL) in OCT B-scans.


Setup

pip install torch transformers Pillow numpy pandas matplotlib tqdm

Usage

  1. Open run_inference.sh and set:

    • INPUT — path to an image, a directory of images, or a .csv file
    • OUTPUT — where to save results (default: ./output)
  2. Run:

bash run_inference.sh

Input formats

Type Example
Single image INPUT="/data/scan.png"
Directory INPUT="/data/oct_bscans/"
CSV file INPUT="/data/scans.csv"

Supported image formats: .png, .jpg, .jpeg, .tif, .tiff, .bmp

If using a CSV, it must have a column containing image paths. The default column name is file_path — change --image_col in run_inference.sh if yours differs.


Outputs

For each image, the following are saved to OUTPUT:

File Description
<stem>_mask.npy Binary segmentation mask as float32 array
<stem>_vis.png Overlay visualization
inference_results.csv Per-image paths summary
inference_summary.json Run metadata

Advanced options

Pass these directly to medsam_inference.py if needed:

Flag Default Description
--device 0 GPU index; use -1 for CPU
--threshold 0.5 Sigmoid threshold for binary mask
--image_col file_path CSV column containing image paths
--no_vis off Skip saving visualization PNGs

About

This model creates a single combined segmentation mask for the RNFL, GCL, and IPL layers for OCT bscans. It was first trained on Topcon Maestro and then spectralis OCTs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors