Traceback (most recent call last):
File "/home/pi/Desktop/testting/client.py"/ line 13, in <module>
modelLSTM = load_model('/home/pi/Desktop/LSTM_model.h5')
File "/home/p/.local/lib/pythone3.7/site-
packages/tensorflow_core/python/keras/saving/save.py", line 146, in
load_model
return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile)
File "/home/p/.local/lib/pythone3.7/site-
packages/tensorflow_core/python/keras/saving/hdf5_format.py", line 166, in
load_model_from_hdf5
model_config = json.loads(model_config.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'
I get this error every time I run this server-client code in python. The code simply sends inputs to the client and the client should predict them but I always get an error when loading the model. This model was saved on my laptop and then transferred using WinSCP to the raspberry pi. There's no problem with the server code which is operating from my laptop. The problem is in the client's code on the raspberry pi.
client:
# author: Bartlomiej "furas" Burek (https://blog.furas.pl)
# date: 2021.07.23
#
# title: receiving back data from the client
# url: https://stackoverflow.com/questions/68499599/receiving-back-
data-from-the-client/68502806#68502806
import socket
import numpy as np
import pandas as pd
import sklearn
from sklearn.preprocessing import MinMaxScaler
from tensorflow.keras.models import load_model
import tensorflow as tf
from random import randint
i = 0
final = []
final = np.array(final)
modelLSTM = load_model('/home/pi/Desktop/LSTM_model.h5')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = '192.168.1.24'
port = 62402
s.connect((host, port))
while True:
if i in range(65533):
i = i + 1
msg = s.recv(64)
out = np.frombuffer(msg)
#out = out.reshape(1,8)
#out = out.reshape(1,1,8)
#prediction = modelLSTM.predict(out)
#inverse = scaler_ti.inverse_transform(prediction.reshape(1,8))
#print(prediction)
#print(inverse)
#final = np.vstack(inverse)
print(out)
if len(msg) <= 0:
break
#print (final)