10000 GitHub - andriiryzhkov/ai_mask_prototype: AI Mask Prototype
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

andriiryzhkov/ai_mask_prototype

Repository files navigation

AI Mask Prototype

Prototype based on Meta's Segment Anything Model implemented in pure C/C++ using GGML tensor library for machine learning.

Description

The prototype currently supports only the ViT-B SAM model checkpoint.

Features

  • Complete SAM model conversion pipeline to GGML format
  • Optimized C/C++ implementation for inference
  • Support for positive and negative point prompts
  • Cross-platform compatibility (Linux, Windows, macOS)
  • Sample applications demonstrating real-world usage

Prerequisites

  • CMake >= 3.12
  • C++14 compatible compiler
  • GGML library
  • OpenCV (for demo applications)
  • Python 3.7+ (for conversion scripts and python demo app)
  • PyTorch (for model conversion)

Installation

  1. Clone the repository:
git clone git@github.com:andriiryzhkov/ai_mask_prototype.git
cd ai_mask_prototype
git submodule update --init --recursive
  1. Create python virtual environment and install dependencies:
poetry install
  1. Download PTH model:
curl --create-dirs --output-dir weights -O https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth
  1. Convert PTH model to ggml format:
poetry run python scripts/convert-pth-to-ggml.py weights/sam_vit_b_01ec64.pth checkpoints/ 1
  1. Build the project:
./build.sh

or manually:

mkdir build && cd build
cmake -G Ninja ..
cmake --build . --config Release -j 8

Run

  1. Run command line inference:
./build/bin/sam_cli -t 12 -i ./images/in/example1.jpg -o ./images/out/example1 -p "2070, 1170, 1" 
./build/bin/sam_cli -t 12 -i ./images/in/example2.jpg -o ./images/out/example2 -p "650, 700, 1" 

or on Windows:

./build/bin/sam_cli.exe -i ./images/in/example1.jpg -o ./images/out/example1 -p "2070, 1170, 1"
./build/bin/sam_cli.exe -i ./images/in/example2.jpg -o ./images/out/example2 -p "650, 700, 1" 
  1. GTK3 application:
./build/bin/sam_gui

or on Windows:

./build/bin/sam_gui.exe
  1. Python demo application with original SAM implementation:
poetry run python scripts/demo.py

Sample images

  1. Photo by Aaron Doucett on Unsplash
  2. Photo by Anoir Chafik on Unsplash

License

GPL3

References

About

AI Mask Prototype

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0