- -
-
-

Gradio

-

Put a beautiful interactive demo layer over your trained ML model.

-

- Get started - See examples - Github -

-
-
- -
-
-

Getting started

-

- Gradio (gradient input-output) is a python library that allows you to easily transform your trained model into a webpage that easily allows you to interface with it. This allows you to: -

    -
  • Show off the model to others
  • -
  • Identify response to unusual behavior
  • -
  • Encourage fairness and reproducibility of your model
  • -
- Gradio is designed to be very simple to use. For example, in just 2 lines of Python code, you can create a sketchpad that allows you write digits and see whether your MNIST model can correctly identify them. -

- -

Installation

-

Gradio is a standard python library, so install it from your terminal like this: -

- - pip install gradio - -
-

-

Usage

-

To use gradio in your code, simply import it, and then launch the appropriate interface -

- - import gradio
- import tensorflow as tf
 
- - model = tf.keras.Sequential()
- # Define your model, as you ordinarily do
- # Train your model, as you ordinarily do
 
- - gradio.interfaces.Sketchpad(model=model, model_type='keras').launch() -
-
-

- - This will open a new browser window which will allow you to draw into a "sketchpad". Behind the scenes, gradio transforms the user drawing into a numeric array and passes it into your model for your prediction. - Then, gradio will fetch the result and show it to the user. Like this: -
 
- Currently, the following model_type are supported: -
    -
  • Keras models
  • -
  • Sklearn models
  • -
  • Arbitrary python functions
  • -
- - See the gallery of interfaces below to see what kind of interfaces can be supported. Contribute your own interfaces by visiting our GitHub page. - -
-

Gallery of Interfaces

- -
-
-
- Card image cap -
-

Draw a Digit: allow users to draw their own digits to test MNIST-type models.

-
-
- - -
- -
-
-
-
-
-
- Card image cap -
-

Emotion Detector: allow users to make emotions through their webcam and detect their emotion with your model.

-
-
- - -
- -
-
-
-
-
-
- Card image cap -
-

Automated Author: use an RNN to generate a sequence of words beginning the words that the user has supplied

-
-
- - -
- -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -