Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import monkey | |
| import tempfile | |
| def encoder(data): | |
| fp = tempfile.NamedTemporaryFile(suffix=".png").name | |
| img = monkey.encode(data) | |
| img.save(fp) | |
| return img, fp | |
| def decoder(input_image): | |
| return monkey.decode(input_image) | |
| idecoder = gr.Interface( | |
| fn=decoder, | |
| inputs=gr.Image(type="pil", label="image to decode"), | |
| outputs=gr.Text(label="decoded text"), | |
| description="### Decode the data stored in your monkeys into readable text.", | |
| ) | |
| iencoder = gr.Interface( | |
| fn=encoder, | |
| inputs=gr.Text(label="text to encode"), | |
| outputs=[gr.Image(label="image"), gr.File(label="download file")], | |
| description="### Encode your highly sensitive text data (/s) into trustworthy monkeys.", | |
| ) | |
| iface = gr.TabbedInterface([iencoder, idecoder], ["encoder", "decoder"]) | |
| iface.launch() | |