Problems with hub.load

I’m using a hosted Flask service at A2 hosting and work from their CPanel. I have installed
tensorboard==2.16.2
tensorboard-data-server==0.7.2
tensorflow==2.16.1
tensorflow-hub==0.16.1
tensorflow-io-gcs-filesystem==0.37.0
tensorflow-text==2.16.1

In my py page

from flask import Flask, request, jsonify, Blueprint
import requests
import tensorflow as tf
import tensorflow_hub as hub
import os

tensorflowapi_bp = Blueprint(‘tensorflowapi’, name)

Load the Universal Sentence Encoder model

#use_model = hub.load(“@tensorflow-models/universal-sentence-encoder”)

#use_model = hub.load(“Google | universal-sentence-encoder | Kaggle”)

model_url = “Google | universal-sentence-encoder | Kaggle
use_model = hub.load(model_url)

As soon as I try to hub.load I get a 500 error for the entire application. As soon as I comment it out the app runs fine… I have tried many different url’s but it seems that the hub.load is the issue. Is this normal? Thank for the help

Hi William

I’ve just tested this on colab and it worked fine:

import tensorflow as tf
import tensorflow_hub as hub

model_url = "https://www.kaggle.com/models/google/universal-sentence-encoder/tensorFlow2/universal-sentence-encoder/2?tfhub-redirect=true"
use_model = hub.load(model_url)

I’m using TF version 2.15, can you try with that?

and maybe there are some information here that might help you: TensorFlow Hub Moving to Kaggle Models - FAQs

I’m new to Python so be easy. I set the TF version to 2.15 in the requirements.txt page in my Flask app and ran it and got the following error:

ERROR: Cannot install -r requirements.txt (line 87) and wrapt==1.16.0 because these package versions have conflicting dependencies.

The conflict is caused by:
The user requested wrapt==1.16.0
tensorflow 2.15.1 depends on wrapt<1.15 and >=1.11.0

To fix this you could try to:

  1. loosen the range of package versions you’ve specified
  2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit Dependency Resolution - pip documentation v24.2.dev0
((api:3.9)) [pythonap@az1-ts114 api]$

Could this be my trouble?

I’m going around in circles-- The conflict is caused by:
The user requested tensorflow==2.15.1
tensorflow-text 2.15.0 depends on tensorflow<2.16 and >=2.15.0; platform_machine != “arm64” or platform_system != “Darwin”
tf-keras 2.16.0 depends on tensorflow<2.17 and >=2.16