Skip to content

WorkTimer/LiteMedSAM_Quantization

 
 

Repository files navigation

LLiteMedSAM Quantization

LiteMedSAM Quantization is an optimized version based on the original MedSAM library. The original repository can be found here: MedSAM GitHub Repository. The quantized version of LiteMedSAM has been deployed as a WEB application, accessible at: LiteMedSAM WEB Application: https://medsam.senma.xyz/. This application allows users to upload two-dimensional medical imaging pictures (in PNG, JPG, JPEG formats) and process them using the quantized version of LiteMedSAM for image segmentation masking.

Medsam.mp4

Installation Guide

Cloning and Installing Dependencies

  1. Clone the repository of the quantized version of LiteMedSAM:
git clone https://github.com/WorkTimer/LiteMedSAM_Quantization/
cd LiteMedSAM_Quantization
  1. Install necessary libraries:
sudo apt-get install libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libxi6 libxtst6
  1. Install conda, refer to the link: Conda Installation Guide.

Creating a Virtual Environment

  1. Create a conda virtual environment named medsam:
conda create -n medsam python=3.10 -y
conda activate medsam
  1. Install Pytorch and related dependencies:
conda install pytorch torchvision -c pytorch
pip install streamlit pandas opencv-python numpy matplotlib pillow pyarrow
pip install -e .

Installing Pytorch 2.0

  1. Enter the MedSAM folder:
cd MedSAM
  1. Run the installation command:
pip install -e .

Downloading Necessary Files

  1. Download the LiteMedSAM checkpoint file lite_medsam.pth and place it in the work_dir/LiteMedSAM directory. Download link: Google Drive.
  2. Download the demo data and place it in the test_demo/ directory. Download link: Google Drive.

Model Testing

Running Test Commands

  1. Test using the original model:
python "CVPR24_LiteMedSAM_infer.py" -i test_demo/imgs/ -o test_demo/segs
  1. Test using the quantized model for accelerated performance:
python "CVPR24_LiteMedSAM_infer_accelerating.py" -i test_demo/imgs/ -o test_demo/segs

WEB Application Operation

Starting and Accessing

  1. Run the following command in the terminal to start the WEB application:
streamlit run /home/scchat/MedSAM/app_streamlit.py --server.port=8501
  1. Access the application in a browser: http:https://<Server_IP>:8501

Please replace <Server_IP> with your actual server IP address. This document provides a basic guide for the installation, configuration, and usage of the quantized version of LiteMedSAM.

Packages

No packages published

Languages

  • Python 99.6%
  • Other 0.4%