GantMan / nsfw_model

Keras model of NSFW detector
Other
1.67k stars 267 forks source link

Getting TypeError: Descriptors cannot not be created directly #154

Closed whiteSkar closed 4 months ago

whiteSkar commented 5 months ago

Getting the error when I am just importing

The import statement: from nsfw_detector import predict

The error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\whiteSkar\git\nsfw_model\nsfw_detector\predict.py", line 11, in <module>
    import tensorflow_hub as hub
  File "C:\Users\whiteSkar\git\nsfw_model\my_venv\lib\site-packages\tensorflow_hub\__init__.py", line 90, in <module>
    from tensorflow_hub.feature_column import image_embedding_column
  File "C:\Users\whiteSkar\git\nsfw_model\my_venv\lib\site-packages\tensorflow_hub\feature_column.py", line 20, in <module>
    from tensorflow_hub import image_util
  File "C:\Users\whiteSkar\git\nsfw_model\my_venv\lib\site-packages\tensorflow_hub\image_util.py", line 17, in <module>
    from tensorflow_hub import image_module_info_pb2
  File "C:\Users\whiteSkar\git\nsfw_model\my_venv\lib\site-packages\tensorflow_hub\image_module_info_pb2.py", line 36, in <module>
    _descriptor.FieldDescriptor(
  File "C:\Users\whiteSkar\git\nsfw_model\my_venv\lib\site-packages\google\protobuf\descriptor.py", line 561, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

Is this supposed to happen?

Vq-x commented 4 months ago

I've got the same problem.

alluding commented 4 months ago

pip install protobuf==3.20.0

whiteSkar commented 4 months ago

thanks that fixed it but now I have another issue..... which I will post in another thread.

Edit: ah that issue is also resolved by this: https://github.com/GantMan/nsfw_model/pull/156.