Forums

Get error when i load Tensorflow Keras model prediction

hello members why i get error when i load tensorflow model from my web site :

http://falahgs.pythonanywhere.com/

020-01-11 10:50:07 2020-01-11 10:49:59.404515: I tensorflow/compiler/xla/service/service.cc:175]   StreamExecutor device (0): Host, Default Version
2020-01-11 10:50:07 /usr/lib/python3.7/site-packages/tensorflow_core/python/framework/indexed_slices.py:424: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory.#012  "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
2020-01-11 10:50:07 xception_model: <keras.engine.training.Model object at 0x7fe3da71dfd0>
2020-01-11 10:50:07 WSGI app 0 (mountpoint='') ready in 11 seconds on interpreter 0x84e380 pid: 1 (default app)
2020-01-11 10:50:07 *** uWSGI is running in multiple interpreter mode ***
2020-01-11 10:50:07 gracefully (RE)spawned uWSGI master process (pid: 1)
2020-01-11 10:50:07 spawned uWSGI worker 1 (pid: 24, cores: 1)
2020-01-11 10:50:07 spawned 2 offload threads for uWSGI worker 1
2020-01-11 10:50:07 metrics collector thread started
2020-01-11 10:50:07 announcing my loyalty to the Emperor...
2020-01-11 10:51:40 filename: /home/falahgs/mysite/uploads/9F127C3.png
2020-01-11 10:51:40 file_path: /home/falahgs/mysite/uploads/3.png
2020-01-11 10:51:40 Begin Model Prediction...

[edit by admin: formatting]

Tensorflow doesn't work in website code on PythonAnywhere -- as you're using Keras, then you should be able to get it working by switching to the Keras backend.

@giles ... thanks for reply... did u mean to change keras.json file from { "floatx": "float32", "epsilon": 1e-07, "backend": "tensorflow", "image_data_format": "channels_last" } to { "floatx": "float32", "epsilon": 1e-07, "backend": "keras", "image_data_format": "channels_last" }

Oops, sorry, I mistyped in my last post. I should have said "switching to the theano backend". So you've found the right thing to change, but it should be "backend": "theano".

@giles thanks for help.. when i change keras.json to :

{ "image_dim_ordering": "th", "epsilon": 1e-07, "floatx": "float32", "backend": "theano" } also i get error message in error.log file

2020-01-13 17:17:38,915: Error running WSGI application 2020-01-13 17:17:38,918: ModuleNotFoundError: No module named 'theano' 2020-01-13 17:17:38,919: File "/var/www/falahgs_pythonanywhere_com_wsgi.py", line 16, in <module> 2020-01-13 17:17:38,919: from flask_app import app as application # noqa 2020-01-13 17:17:38,919:

how to install theano in pythonanywhere site hosting ...? or in my code setting to theano package ...?

thanks for help

Here you go: http://help.pythonanywhere.com/pages/InstallingNewModules/

I tried changing the backend to 'theano'. This does not solve the issue. There are no errors however, when it comes to prediction, it doesnt do anything.. It justs hangs on there. Any solutions please.. Is there a particular version of tensorflow that works? It works fine on the console though :( strange

Add some debugging code to see where it hangs.

I get the same error ...still the same error with tenserflow and theano...!!! i don't know why pythonanywhere dosen't work very well with tensetflow backend .

What error? There are a number of errors being discussed in this thread.