Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SAM2 (float) #90

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Added SAM2 (float) #90

wants to merge 20 commits into from

Conversation

kyakuno
Copy link
Contributor

@kyakuno kyakuno commented Aug 28, 2024

Image mode (TensorFlow)

python3 segment-anything-2.py --tflite

Video mode(TensorFlow)

python3 segment-anything-2.py --tflite -v demo

As a constraint, TensorFlow does not support DynamicShape, so the specified point becomes one.

#88

@kyakuno
Copy link
Contributor Author

kyakuno commented Aug 28, 2024

With tensorflow-macos Version: 2.12.0, the ImageEncoder cannot be inferred.

  File "/Users/kyakuno/Desktop/ailia/ailia-models-tflite/image_segmentation/segment-anything-2/sam2_image_predictor.py", line 30, in set_image
    image_encoder.allocate_tensors()
  File "/usr/local/lib/python3.11/site-packages/tensorflow/lite/python/interpreter.py", line 507, in allocate_tensors
    return self._interpreter.AllocateTensors()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Given shapes, [1,255,256,144] and [1,256,256,144], are not broadcastable.Node number 204 (ADD) failed to prepare.Failed to apply the default TensorFlow Lite delegate indexed at 0.

With tensorflow Version: 2.17.0, it can be inferred.

@kyakuno
Copy link
Contributor Author

kyakuno commented Aug 28, 2024

tflite's output tensor order becomes random.

@kyakuno
Copy link
Contributor Author

kyakuno commented Aug 30, 2024

Support for the Tiny model has been added.

python3 segment-anything-2.py --model_type hiera_t --tflite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant