Skip to content

Instantly share code, notes, and snippets.

@fmind
Last active January 7, 2022 08:24
Show Gist options
  • Save fmind/c2dd9e4a5c848d260c0003170d2ea73f to your computer and use it in GitHub Desktop.
Save fmind/c2dd9e4a5c848d260c0003170d2ea73f to your computer and use it in GitHub Desktop.
Snippets for Gradio app.
"""Start a simple Gradio application."""
# IMPORTS
import gradio as gr
# CONFIGS
TITLE = "Gradio App"
ARTICLE = """
# Instructions
TODO
"""
# FUNCTIONS
def gui_fn(x: int) -> int:
"""Increment a number."""
return x + 1
# INTERFACES
inputs = [
gr.inputs.Slider(
label="X",
default=0,
),
]
outputs = [
gr.outputs.Textbox(
label="Y",
type="number",
),
]
gui = gr.Interface(
# main
fn=gui_fn,
inputs=inputs,
outputs=outputs,
# meta
title=TITLE,
article=ARTICLE,
# flags
allow_flagging=False,
allow_screenshot=False,
)
# CONDITIONS
if __name__ == "__main__":
gui.launch(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment