What I’m trying to do:
I’m building a website for a user to train image classification model. Afterwards i’m providing a download button to download the trained model. It is working perfectly but the model is taking too long to download it. Around 10 to 15 minutes, but when i’m trying to download the model without anvil, it is just taking few seconds to download. Why is that? and how can i minimize the time taken?
What I’ve tried and what’s not working:
I am using the following code to download the model. The variable “m2” contains the tensorflow model which i intend to download.
Server code:
@anvil.server.callable
def download():
if m2 is not None:
saved = m2.save('my_model.h5', save_format='h5')
import anvil.media
media_obj = anvil.media.from_file('my_model.h5')
return media_obj
else:
return None
Anvil code:
def button_1_click(self, **event_args):
text_file = anvil.server.call('download')
if text_file == None:
print("Model is not ready to download")
else:
anvil.media.download(text_file)
There are alot of things going on in the website, therefore not sharing the clone link to avoid the mess.