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

Bug: AttributeError: module 'numpy' has no attribute 'object'. #910

Open
mazin01 opened this issue Apr 30, 2024 · 1 comment
Open

Bug: AttributeError: module 'numpy' has no attribute 'object'. #910

mazin01 opened this issue Apr 30, 2024 · 1 comment

Comments

@mazin01
Copy link

mazin01 commented Apr 30, 2024

What happened?

I'm trying to convert a model that I fine tuned in python to tensorflow js format to use it in the web.

the fine tuned model folder has the following files:

  • config.json
  • generation_config.json
  • model.safetensors
  • special_tokens_map.json
  • tokenizer_config.json
  • tokenizer.json

I followed the same instructions for converting it using both tensorflowjs_convertor and tensorflowjs_wizard its all returning the same error bellow.

Relevant code

## command line code 1

tensorflowjs_converter \    --input_format=tf_saved_model \    --output_node_names='finetuned_task_to_json_model' \    --saved_model_tags=serve \    ./llm-testing/task_to_json_fine_tuned_model \    ./llm-testing/task_to_json_fine_tuned_tfjs_model


## command line code 2
tensorflowjs_wizard

Relevant log output

C:\Users\User_Name\AppData\Roaming\Python\Python312\site-packages\tensorflowjs\read_weights.py:28: FutureWarning: In the future `np.object` will be defined as the corresponding NumPy scalar.
  np.uint8, np.uint16, np.object, np.bool]
Traceback (most recent call last):
  File "c:\Users\User_Name\Projects\Local\random-scripts\llm-testing\fine-tuning-model.py", line 70, in <module>
    import tensorflowjs as tfjs
  File "C:\Users\User_Name\AppData\Roaming\Python\Python312\site-packages\tensorflowjs\__init__.py", line 21, in <module>
    from tensorflowjs import converters
  File "C:\Users\User_Name\AppData\Roaming\Python\Python312\site-packages\tensorflowjs\converters\__init__.py", line 21, in <module>
    from tensorflowjs.converters.converter import convert
  File "C:\Users\User_Name\AppData\Roaming\Python\Python312\site-packages\tensorflowjs\converters\converter.py", line 35, in <module>
    from tensorflowjs.converters import keras_h5_conversion as conversion
  File "C:\Users\User_Name\AppData\Roaming\Python\Python312\site-packages\tensorflowjs\converters\keras_h5_conversion.py", line 33, in <module>
    from tensorflowjs import write_weights  # pylint: disable=import-error
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User_Name\AppData\Roaming\Python\Python312\site-packages\tensorflowjs\write_weights.py", line 25, in <module>
    from tensorflowjs import read_weights
  File "C:\Users\User_Name\AppData\Roaming\Python\Python312\site-packages\tensorflowjs\read_weights.py", line 28, in <module>
    np.uint8, np.uint16, np.object, np.bool]
                         ^^^^^^^^^
  File "C:\Python312\Lib\site-packages\numpy\__init__.py", line 338, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'object'.
`np.object` was a deprecated alias for the builtin `object`. To avoid this error in existing code, use `object` by itself. Doing this will not modify any behavior and is safe. 
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'object_'?

tensorflow_hub Version

0.12.0 (latest stable release)

TensorFlow Version

2.8 (latest stable release)

Other libraries

No response

Python Version

3.x

OS

Windows

@KeijiBranshi
Copy link
Collaborator

Hi @mazin01,

Apologies for the delayed response.

This looks more like a tensorflowjs issue than anything to do with tensorflow_hub. I found this resolved issue that looks similar to your situation:

tensorflow/tfjs#8030

tl;dr - it looks Windows is not supported for some tensorflowjs workflows

For future questions on tensorflowjs, I'd recommend creating an issue over on that repository.

Thanks, and happy modeling!

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

No branches or pull requests

2 participants