Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



 372

Looking for a fix on this python code, worked for 2+ years, now it doesnt

by allnightv - 28 June, 2024 - 01:41 AM
This post is by a banned member (allnightv) - Unhide
allnightv  
Registered
20
Posts
3
Threads
1 Year of service
#1

  1. 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-text 2.16.1 requires tensorflow<2.17,>=2.16.1; platform_machine != "arm64" or platform_system != "Darwin", but you have tensorflow 2.15.0 which is incompatible.
  2. [2:48 PM]
    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. tf-keras 2.15.1 requires tensorflow<2.16,>=2.15, but you have tensorflow 2.16.1 which is incompatible.
  3. [2:48 PM]
    ImportError: cannot import name 'ops' from 'keras' (/usr/local/lib/python3.10/dist-packages/keras/init.py)

this is what I'm getting on my end

if anyone has suggestions or knows how to fix it, please let me know, can pay
This post is by a banned member (wwwtmp) - Unhide
This post is by a banned member (allnightv) - Unhide
allnightv  
Registered
20
Posts
3
Threads
1 Year of service
#3
(This post was last modified: 28 June, 2024 - 04:31 AM by allnightv.)
Sure, here's a concise version of your question, ready to send on GitHub:

---

Title: Trouble Loading and Using a TensorFlow SavedModel with Custom Input Layer in Keras

Body:

Hi everyone,

I'm currently working on a project where I need to load a TensorFlow SavedModel and use it with a custom input layer in Keras. However, I'm running into issues when trying to perform inference with the model. Here’s what I’ve done so far:

1. Loaded the SavedModel as an inference-only layer:
       import tensorflow as tf
    from keras.layers import TFSMLayer
    from keras import Input
    from keras.models import Model

    base_model = TFSMLayer("path/to/savedmodel", call_endpoint='serving_default')

    input_layer = Input(shape=(32,), dtype='float64')

    output_layer = base_model(input_layer)

    model = Model(inputs=input_layer, outputs=output_layer)
    
2. Converted test data to the required float64 dtype:
       import pandas as pd

    test_data = pd.read_csv("path/to/testdata.csv")
    test_data_float64 = tf.cast(test_data.values, tf.float64)
    
3. Attempted to use the model for inference:
       predictions = model(test_data_float64)
    
However, I’m encountering issues with the input data type and shape compatibility. 

### My Questions:

1. Data Type Compatibility: How can I ensure that the input data is correctly formatted and compatible with the expected input dtype of the TFSMLayer?
2. Shape Issues: Are there any common pitfalls or best practices when dealing with custom input layers in Keras models that load TensorFlow SavedModels?
3. Inference with Custom Layers: Is there a better approach to modify the input layer of a pre-trained TensorFlow SavedModel for inference in Keras?

Any guidance or suggestions on how to resolve these issues would be greatly appreciated. Thank you!

---

(28 June, 2024 - 01:42 AM)wwwtmp Wrote: Show More
I requires tensorflow<2.17,>=2.16.1; platform_machine != "arm64" or platform_system != "Darwin", but you have tensorflow 2.15.0 which is incompatible

I believe that we need it to be at 2.15 for the data compile or whatever, once my dev responds to this in the morning i will relay his message over and quite possibly you might have a solution
This post is by a banned member (UberFuck) - Unhide
UberFuck  
Godlike
1.557
Posts
375
Threads
5 Years of service
#4
This is why you're supposed to use virtual environments. Try running pipdeptree on your project to see if there are any conflicts.

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 1 Guest(s)