Giter Site home page Giter Site logo

newgrit1004 / efficientsam Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yformer/efficientsam

0.0 0.0 0.0 283.15 MB

EfficientSAM: Leveraged Masked Image Pretraining for Efficient Segment Anything

License: Apache License 2.0

Shell 0.02% Python 1.67% Jupyter Notebook 98.21% Dockerfile 0.06% HTML 0.01% PureBasic 0.01% JavaScript 0.03%

efficientsam's Introduction

reproduce step

1. clone this repository and set the model files.

  git clone --recurse-submodules https://github.com/newgrit1004/EfficientSAM.git
  cd EfficientSAM
  unzip weights/efficient_sam_vits.pt.zip
  mv efficient_sam_vits.pt ./weights

2. build the docker image

# check the cuda version in Dockerfile. Modify the base image depending on your environment.
docker compose -f docker-compose-build.yml build

docker compose up -d
docker exec -it tfjs_test /bin/bash -c "cd /workspace && /bin/bash"

# inside the container
python export_to_onnx.py # generated onnx files are in "./weights" folder.
python export_onnx_to_tensorflow.py # generated tensorflow files are in "./saved_model" folder.

# if python export_onnx_to_tensorflow.py is not executed,
# install the onnx_tf manually inside the container.
docker exec -it tfjs_test /bin/bash -c "cd /workspace && /bin/bash"
root@b9fb8b01ab27:/workspace# cd onnx-tensorflow/
root@b9fb8b01ab27:/workspace/onnx-tensorflow# pip install -e .
root@b9fb8b01ab27:/workspace/onnx-tensorflow# cd ../
root@b9fb8b01ab27:/workspace# python export_to_onnx.py
root@b9fb8b01ab27:/workspace# python export_onnx_to_tensorflow.py

3. compare torch model and tensorflow model result

  • See the jupyter notebook "compare_tf_torch_result.ipynb" file.
  • Run the jupyter notebook in local(tensorflow 2.16.1 required)
python3 -m venv .venv
. .venv/bin/activate
pip3 install -r requirements.txt

# Then run the jupyter notebook cells in order.

4. Convert the tensorflow model into tfjs model

docker compose up -d
docker exec -it tfjs_test /bin/bash -c "cd /workspace && /bin/bash"

# inside the container
pip install tensorflow==2.16.1
tensorflowjs_converter \
      --input_format tf_saved_model \
      --output_format tfjs_graph_model \
      saved_model \
      tfjs_model # generated tfjs_model files are in "./tfjs_model" folder.

5. See the result of tensorflow.js model inference

Right click on index.html file then click "open with live server."

See the result on console.

efficientsam's People

Contributors

balakv504 avatar yformer avatar klightz avatar newgrit1004 avatar spacewalk01 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.