numpy incompatibility

#9
by gordonnoah - opened

Anyone know the last compatible numpy version. Im experiencing some issues that appear to be a known issue with other users as well. I cant find any requirements file in the source code and the repo is no longer maintained. I suspect downgrading to latest compatible np will be a workaround

The code im running is snippet provided by hf and in the lib docs

import fasttext
from huggingface_hub import hf_hub_download, snapshot_download

model_path = hf_hub_download(repo_id="facebook/fasttext-language-identification", filename="model.bin")
model = fasttext.load_model(model_path)
model.predict("Hello, world!")

PARTIAL TRACE:

.py", line 239, in predict
    return labels, np.array(probs, copy=False)
ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.

Did anyone find the fix for this? I am getting the same error

I think fasttext library is not compatible to the new versions of numpy. But also Meta stop maintaining the library... so what I did was change the line number 239 of the file FastText.py and it worked.

It was like that:

return labels, np.array(probs, copy=False)

And I changed to this:

return labels, np.asarray(probs)

I created a fork of fasttext with this modifications, you can check the changes here: https://github.com/thomas-ferraz/fastText/commit/0ffafb256d3f6325f8e5dbd527b4e22c1a7e49d2

Sign up or log in to comment