Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import urllib | |
| from PIL import Image | |
| karlo = gr.Interface.load(name="spaces/kakaobrain/karlo") | |
| def get_images(prompt): | |
| try: | |
| gallery_dir = karlo(prompt, fn_index=1) | |
| except Exception as e: | |
| text=str(e) | |
| url = "https://kakaobrain-karlo.hf.space/file="+text[38:len(text)-1] | |
| save_as = "file.png" | |
| data1 = urllib.request.urlopen(url) | |
| f = open(save_as,'wb') | |
| f.write(data1.read()) | |
| f.close() | |
| img = Image.open(save_as) | |
| return img | |
| demo=gr.Interface(fn=get_images, | |
| inputs="text", | |
| outputs="image", | |
| examples=[["A man with a face of avocado, in the drawing style of Rene Magritte"], ["a black porcelain in the shape of pikachu"], ["a portrait of an old monk, highly detailed"], ["A teddy bear on a skateboard, children drawing style."]], | |
| title="Karlo CPU/API") | |
| demo.launch(debug=True) |