axinc-ai / ailia-models-tflite

Quantized version of model library
24 stars 2 forks source link

Added SAM2 (float) #90

Open kyakuno opened 2 months ago

kyakuno commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

tflite's output tensor order becomes random.

kyakuno commented 2 months ago

Support for the Tiny model has been added.

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