This is an script for the annotation tool implementation developed for polygonal binary annotation using Segment Anything Model (SAM)'
Install all the packages in requirements.txt file. The code was executed in a Python 3.10.11 envirionment. The code was run with a Tesla T4 GPU. To use a similar GPU, please ensure you have the appropriate CUDA and cuDNN packages installed.
pip install -r requirements.txt
conda install --file requirements.txt
Install the Segment anything model by following the instructions from SAM GitHub repository Also Download the pretrained weights from the model checkpoint and save it under weights/sam_vit_h_4b8939.pth
.
To run the script:
python ann.py
-
Modify the Folders:
- Update the respective input and output folders in the
ann.py
file. - Run the file.
- Update the respective input and output folders in the
-
Open First Frame:
- The first frame will open in a separate window.
-
Annotate Object:
- Draw a rough bounding box around the object you wish to annotate.
- Press the "s" key to run the model.
-
Review Annotation:
- A binary mask for the object will be generated.
- If you are satisfied with the annotation, press the "s" key again to save it in the output folder.
- If you are not satisfied, press the "c" key to cancel the bounding box and return to step 3.
-
Next Frame:
- The next frame in the input folder will automatically open.
- Repeat step 3 until all frames are annotated.