Gradio

Gradio is all about user interface, it is a startup that got acquired by Hugging Face !

In your python code, you execute the following line

import gradio as gr # The way people usually call it

now, here is an example that turns your text to uppercase

def to_uppercase(text):
return text.upper()

Now, to get a user interface, run the following code

gr.Interface(fn=to_uppercase, inputs="textbox", outputs="textbox").launch()

Now, you should be getting 2 boxes, one for your input, and the other to display your text in uppercase

Now, imagine the to_uppercase function being a call to an AI, so there you have it

Here is a variant with big boxes

# Inputs and Outputs

view = gr.Interface(
fn=to_uppercase,
inputs=[gr.Textbox(label="Your message:", lines=6)],
# outputs=[gr.Textbox(label="Response:", lines=8)],
outputs=[gr.Markdown(label="Response:")],
flagging_mode="never"
)
view.launch()

At this point, when you run this, you should get the link to the URL with that user interface !

Posted in AI

Leave a Reply

Your email address will not be published. Required fields are marked *