Python "struct.error: unpack_from requires a buffer of at least 1718886439 bytes for unpacking 4 bytes at offset 1718886435 (actual buffer size is 361)" #8347
Traceback (most recent call last):
File "/home/ethan/Projects/MachineLearning/Gemini-Nano/playground/analyzer.py", line 11, in <module>
print(f"Version: {model.Version()}")
^^^^^^^^^^^^^^^
File "/home/ethan/Projects/MachineLearning/Gemini-Nano/playground/tflite/Model.py", line 40, in Version
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
^^^^^^^^^^^^^^^^^^^
File "/home/ethan/miniforge3/envs/Gemini-Nano/lib/python3.12/site-packages/flatbuffers/table.py", line 37, in Offset
vtable = self.Pos - self.Get(N.SOffsetTFlags, self.Pos)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ethan/miniforge3/envs/Gemini-Nano/lib/python3.12/site-packages/flatbuffers/table.py", line 93, in Get
return flags.py_type(encode.Get(flags.packer_type, self.Bytes, off))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ethan/miniforge3/envs/Gemini-Nano/lib/python3.12/site-packages/flatbuffers/encode.py", line 26, in Get
return packer_type.unpack_from(memoryview_type(buf), head)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
struct.error: unpack_from requires a buffer of at least 1718886439 bytes for unpacking 4 bytes at offset 1718886435 (actual buffer size is 361)
The tflite directory was created by flatc --python --python-typing schema_v3c.fbs, where schema_v3c.fbs is the tflite v3c schema. The model can be any MediaPipe LLM, such as the Gemini Nano included in Chrome Canary.
When trying to load an LLM in TensorFlow MediaPipe format, using the following code:
I get:
The
tflite
directory was created byflatc --python --python-typing schema_v3c.fbs
, whereschema_v3c.fbs
is the tflite v3c schema. The model can be any MediaPipe LLM, such as the Gemini Nano included in Chrome Canary.