My client code is supposed to get the contents of a .weights.h5 file from the server in it's response.
response=requests.get(url)
if response.status_code == 200:
weights_file_contents=response.content
After getting it I want to load it into a model with model.load_weights(file_path). However since this method only accepts file path I'm saving this to a temporary file and deleting it after use.
file_path = "temp.weights.h5"
with open(file_path, 'wb') as file:
file.write(weights_file_contents)
model.load_weights(file_path)
os.remove(file_path)
Is it possible to pass this file contents through python to that method without creating any external file at all?