Spaces:
Runtime error
Runtime error
File size: 631 Bytes
585ffc7 e258875 585ffc7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import gradio as gr
import base64
from io import BytesIO
def run(image):
if image is None:
raise gr.Error('No input image')
buffer = BytesIO()
image.save(buffer, format='PNG')
img_str = base64.b64encode(buffer.getvalue()).decode("utf-8")
return img_str
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
image = gr.Image(type='pil', interactive=True)
submit = gr.Button()
output_text = gr.Textbox(interactive=False)
submit.click(
fn=run,
inputs=[image],
outputs=[output_text],
)
demo.launch(show_error=True)
|