SAMBA
(Segment Anything Model Based App) is a trainable segmentation tool for materials science that uses deep learning for fast, high-quality labels and random forests for robust, generalizable segmentations. It is accessible in the browser (https://www.sambasegment.com), without the need to download any external dependencies. This repo is a local version of the website which contains the frontend for the website (React + TSX) and the backend (Python + Flask). The frontend handles labelling and the backend sends back SAM embeddings (if requested) and segmentations.
Check out the tutorial/user manual if help is needed!
These instructions are for installing and running the model locally. They assume a UNIX enviroment (mac or linux), but adapting for Windows is straightforward. Note you will need 2 terminals, one for the frontend local server and one for the backend local server.
Download one of the ViT checkpoints for the SAM model - I chose the smallest, vit_b
: ViT-B SAM model. Copy this into the backend/
directory.
- Setup a virtual environment in Python and activate it (not necessary but recommended)
- Install libraries from
backend/requirements.txt
:
pip install -r backend/requirements.txt
- With your virtual environment activated and inside the
backend/
directory, run
python -m flask --app server run
The server is now setup and listening for requests from our frontend!
- Install the JS libraries needed to build and run the frontend. Install Yarn (and npm first if needed)
npm install --g yarn
- Build and run:
yarn && yarn start
- Navigate to
http://localhost:8081/
orhttp://localhost:8080/
depending on the port (it should do this automatically).
- Run (with your virtual enviroment activated!)
python backend/tests.py $FIJI_PATH
where $FIJI_PATH
is the absolute path to your FIJI installation.