Writing image(s) into user's desired directory on his own PC

No, this is it. This function lets me download the entire model.

I think you’re right, i missed the RETURN keyword. This is my code now:

@anvil.server.callable
def download(path):
    if m is not None:
        return m.save(path)
  def button_2_click(self, **event_args):
    text_file = anvil.server.call('download' ,self.d.text)
    anvil.media.download(text_file)
    pass

and i’m still getting this error:

Exception: Argument to anvil.download() must be a Media object
at Form1, line 32

Although the model is still being saved on the path i provided but it is also throwing the above error.

Yes, that part is saving the model in my computer. I’m taking user input path from where i take images for training of model, also i take single input image to test the model after successful training.

Then i train the model using function “task” (output gets saved in variable “model”). Since i wanna use “model” variable for downloading, for simplicity i call it “m”.

Have a look at my server side code: