Gradio fundamentals
The preceding sample code is reformed from the Gradio official quick start tutorial. When we look at the code, lots of details are hidden. We don’t know where the Clear
button is, we don’t specify the Submit
button, and we don’t know what the Flag
button is.
Before using Gradio for any serious applications, we need to understand every line of code and ensure every element is under control.
Instead of using the Interface
function to automatically provide the layout, Blocks
may provide a better way for us to add interface elements with explicit declaration.
Gradio Blocks
The Interface
function provides an abstraction level to easily create quick demos, but there is an abstraction layer. Easy comes with a price. Blocks
, on the other hand, is a low-level approach to lay out elements and define data flows. With the help of Blocks
, we can precisely control the following:
- The layout of components
- The events that trigger actions...