I have trained a tensorflow model and saved it in the form of a .h5
file, about the size of 700mb. What’s the most efficient way to load this into the web app. I have tried storing it on digitalOcean space, but loading is not very efficient, takes about over 45 seconds. Any tips for speeding this up? Below is the code I used to load the model.
def load():
session1 = session.Session()
client = session1.client('s3',
region_name='nyc3',
endpoint_url=DO_SPACES_ENDPOINT,
aws_access_key_id=DO_SPACES_ACCESS_KEY,
aws_secret_access_key=DO_SPACES_SECRET_KEY)
model_object = client.get_object(Bucket=BUCKET_NAME, Key=WEIGHTS_FILE)
model_content = model_object['Body'].read()
with tempfile.NamedTemporaryFile(suffix='.h5', delete=False) as fp:
fp.write(model_content)
model_path = fp.name
return model_path
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi There, can you share where you are running this app relative to the bucket? Are they in the same datacenter?