import gradio as gr from PIL import Image import math import re from twords import Twords twords=Twords() with gr.Blocks() as app: with gr.Row(): with gr.Tab("Encode"): txt=gr.Textbox() btn=gr.Button("Encode") im = gr.Image() with gr.Tab("Decode"): in_im=gr.Image(type='pil') dec_btn=gr.Button("Decode") txt_out=gr.Textbox() with gr.Row(visible=False): rev=gr.JSON() box=gr.JSON() out=gr.JSON() dec_btn.click(twords.decode_im,[in_im],txt_out) btn.click(twords.token_words,txt,[im,in_im]) app.launch()