google / yggdrasil-decision-forests

A library to train, evaluate, interpret, and productionize decision forest models such as Random Forest and Gradient Boosted Decision Trees.
https://ydf.readthedocs.io/
Apache License 2.0
498 stars 53 forks source link

getting protobuf downgrading issue #38

Closed 1kaiser closed 1 year ago

1kaiser commented 1 year ago
######################$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$<<< tensorflow model
#Copy and execute the following code in a new Google Colab notebook launch to run the model.
!python -m pip install tensorflow tensorflow_decision_forests -U -qq

# Transfer the model from Google Drive to Colab
from google.colab import drive
drive.mount("/content/gdrive")
!cp "/content/gdrive/My Drive/simple_ml_for_sheets/Ice height from bands" ydf_model

# Prepare and load the model with TensorFlow
import tensorflow as tf
import tensorflow_decision_forests as tfdf

tfdf.keras.yggdrasil_model_to_keras_model("ydf_model", "tfdf_model")
model = tf.keras.models.load_model("tfdf_model")
######################$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$<<< tensorflow model

output from google colab

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 462.5/462.5 KB 18.2 MB/s eta 0:00:00
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow-metadata 1.12.0 requires protobuf<4,>=3.13, but you have protobuf 4.22.1 which is incompatible.
Drive already mounted at /content/gdrive; to attempt to forcibly remount, call drive.mount("/content/gdrive", force_remount=True).
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[<ipython-input-10-257986a1557a>](https://localhost:8080/#) in <module>
     17 # Prepare and load the model with TensorFlow
     18 import tensorflow as tf
---> 19 import tensorflow_decision_forests as tfdf
     20 
     21 tfdf.keras.yggdrasil_model_to_keras_model("ydf_model", "tfdf_model")

8 frames
[/usr/local/lib/python3.9/dist-packages/google/protobuf/descriptor.py](https://localhost:8080/#) in __new__(cls, name, index, number, type, options, serialized_options, create_key)
    794                 type=None,  # pylint: disable=redefined-builtin
    795                 options=None, serialized_options=None, create_key=None):
--> 796       _message.Message._CheckCalledFromGeneratedFile()
    797       # There is no way we can build a complete EnumValueDescriptor with the
    798       # given parameters (the name of the Enum is not known, for example).

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
1kaiser commented 1 year ago

Compatibility table

The following table shows the compatibility between tensorflow_decision_forests and its dependencies:

tensorflow_decision_forests | tensorflow -- | -- 1.1.0 - 1.2.0 | 2.11.0 1.0.0 - 1.0.1 | 2.10.0 - 2.10.1 0.2.6 - 0.2.7 | 2.9.1 0.2.5 | 2.9 0.2.4 | 2.8 0.2.1 - 0.2.3 | 2.7 0.1.9 - 0.2.0 | 2.6 0.1.1 - 0.1.8 | 2.5 0.1.0 | 2.4

image

rstz commented 1 year ago

Hi,

Thank you for the report, I'll have a look. Most likely, this is indeed due to incompatibility between TF 2.12.0 and the current TF-DF - as you can see, TF-DF has not yet been updated on PyPi, but we should get to this very soon.

Best, Richard

1kaiser commented 1 year ago

i got to get it working ✅ by >>> removing the tensorflow install command

######################$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$<<< tensorflow model
#Copy and execute the following code in a new Google Colab notebook launch to run the model.
!python -m pip install tensorflow_decision_forests -U -qq

# Transfer the model from Google Drive to Colab
from google.colab import drive
drive.mount("/content/gdrive")
!cp "/content/gdrive/My Drive/simple_ml_for_sheets/Ice height from bands" ydf_model

# Prepare and load the model with TensorFlow
import tensorflow as tf
import tensorflow_decision_forests as tfdf

tfdf.keras.yggdrasil_model_to_keras_model("ydf_model", "tfdf_model")
model = tf.keras.models.load_model("tfdf_model")
######################$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$<<< tensorflow model