Cannot load file containing pickled data

*This question was migrated from Github Discussions.

Original questions:
I’ve just started using FLower and I’m getting this error

raise ValueError("Cannot load file containing pickled data " ValueError: Cannot load file containing pickled data when allow_pickle=False

Could you help me find a solution?
Thanks in advance"

Answer (part 1):
“Hi! You seem to be trying to load a pickled file (are you using numpy.load ?), if you know the content of the file you are trying to load and know you can trust it, you should probably use numpy.load with allow_pickle=True . If you can share some of the code that leading to the error I could probably assist you with more certainty, but hope this already helps!”

Answer (part 2):
"Hello, thank you for your reply.
The error occurred in this piece of code:

def bytes_to_ndarray(tensor: bytes) -> NDArray: 
"""Deserialize NumPy ndarray from bytes.""" 
bytes_io = BytesIO(tensor)
# WARNING: NEVER set allow_pickle to true. 
# Reason: loading pickled data can execute arbitrary code 
# Source: ndarray_deserialized = np.load(bytes_io, allow_pickle=False) 
return cast(NDArray, ndarray_deserialized)

The problem came from the bytes I was sending for deserialization. I was able to solve the problem by reviewing the format of the bytes I was sending."