What I’m trying to do:
I am trying to input some text in Anvil app and the google colab connected to Anvil sever will generate the image based on pre-trained model.
What I’ve tried and what’s not working:
I have got the following error. I don’t know what is wrong, so help me out?
anvil.server.SerializationError: Cannot serialize return value from function. Cannot serialize <class 'PIL.Image.Image'> object at msg['response']
at Form1, line 32
anvil.server.SerializationError: Cannot serialize return value from function. Cannot serialize <class 'PIL.Image.Image'> object at msg['response']
at Form1, line 32
Code Sample:
# Get the results
def click_button_click(self, **event_args):
"""This method is called when the button is clicked"""
text_to_image = anvil.server.call('text_to_image',
self.input_text.text)
# If a category is returned set our species
if text_to_image:
self.display.visible = True
self.display.text = "The result is "
# this is a formatted code snippet.
# paste your code between ```
Colab Code
@anvil.server.callable
def text_to_image(input_text):
model = clip.tokenize([input_text])
return to_show_img
Clone link:
share a copy of your app
https://anvil.works/build#clone:WLYN4T2O5LXVWSMJ=NLZOG2JUIQFRX3ETELBWAR2C