Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sardinecan/segmentanything.jl
A julia wrapper for Segment Anything.
https://github.com/sardinecan/segmentanything.jl
Last synced: 5 days ago
JSON representation
A julia wrapper for Segment Anything.
- Host: GitHub
- URL: https://github.com/sardinecan/segmentanything.jl
- Owner: sardinecan
- License: gpl-3.0
- Created: 2024-10-10T14:46:58.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-11-10T16:57:49.000Z (2 months ago)
- Last Synced: 2024-11-15T01:34:38.383Z (2 months ago)
- Language: Julia
- Size: 46.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SegmentAnything.jl
## Installation
### Dependencies
#### Python
`SegmentAnything.jl` requires `python 3.8.6` with the following packages:
- `segment anything`
- `cv2`
- `matplotlib.pyplot`
- `numpy`
- `torch`You can use [`pyenv`](https://github.com/pyenv/pyenv) to handle multiple versions of python on your computer. Once `pyenv` installed, run `pyenv install 3.8.6` and `pyenv global 3.8.6` to add and to activate the required version on your machine.
There is a `requirements.txt` file into `SegmentAnything.jl/deps/python/`. To install the python environment, you just need to create a virtual env and add the packages with the following commands
```python
# change directory
cd SegmentAnything.jl/deps/python# create venv
python3 -m venv .venv# activate venv
source .venv/bin/activate# install python packages from requirements.txt
pip3 install -r requirements.txt
```
#### SAM
`SegmeAnything.jl` needs the [Segment Anything Model Checkpoints](https://github.com/facebookresearch/segment-anything?tab=readme-ov-file#model-checkpoints). To download the 3 checkpoints, just run the `download_sam.jl` file located at `SegmentAnything/deps/sam`.### SegmentAnything.jl
- Clone the repo
- In a terminal emulator, change the working directory: `cd path/to/SegmentAnything.jl`
- Activate the julia env in the julia REPL: `pkg> activate.`
- Instantiate the env to install deps: `pkg> instantiate`
- Then, load the module: `julia> include("SegmentAnything.jl")`## Getting Started
### Automatic segmentation
To perform an automatic segmentation, just run the `segment_image()` function. This function takes two arguments, the `image path` and a `sam checkpoint` (`vit_b`, `vit_l` or `vit_h`).
```julia
julia> image = "path/to/image"
julia> segmentation = SegmentAnything.segment_image(image, "vit_b")
```To display the masks over image, use the `show_anns_jl()` function.
```julia
julia> SegmentAnything.show_anns_jl(segmentation, image)
```