2019-01-25 15:34:09 +08:00
# Gradiome / Gradio
2019-02-20 12:39:21 +08:00
`Gradio` is a python library that allows you to place input and output interfaces over trained models to make it easy for you to "play around" with your model. Gradio runs entirely locally using your browser.
2019-01-25 15:34:09 +08:00
2019-02-20 12:39:21 +08:00
To get a sense of `gradio` , take a look at the python notebooks in the `examples` folder, or read on below!
2019-01-25 15:34:09 +08:00
2019-02-20 12:39:21 +08:00
## Installation
```
pip install gradio
```
(you may need to replace `pip` with `pip3` if you're running `python3` ).
## Usage
2019-02-20 14:26:48 +08:00
Gradio is very easy to use with your existing code. The general way it's used is something like this:
2019-02-20 12:39:21 +08:00
2019-02-20 14:26:48 +08:00
```python
2019-02-20 12:39:21 +08:00
import tensorflow as tf
import gradio
mdl = tf.keras.models.Sequential()
# ... define and train the model as you would normally
2019-02-21 00:45:44 +08:00
iface = gradio.Interface(input=“sketchpad”, output=“class”, model_type=“keras”, model=mdl)
2019-02-20 12:39:21 +08:00
iface.launch()
```
Changing the `input` and `output` parameters in the `Interface` face object allow you to create different interfaces, depending on the needs of your model. Take a look at the python notebooks for more examples. The currently supported interfaces are as follows:
**Input interfaces**:
* Sketchpad
* ImageUplaod
* Webcam
* Textbox
**Output interfaces**:
* Class
* Textbox
## Screenshots
2019-02-20 12:46:44 +08:00
Here are a few screenshots that show examples of gradio interfaces
2019-02-20 12:47:45 +08:00
#### MNIST Digit Recognition (Input: Sketchpad, Output: Class)
2019-02-20 14:26:48 +08:00
```python
iface = gradio.Interface(input='sketchpad', output='class', model=model, model_type='keras')
iface.launch()
```
2019-02-20 14:24:29 +08:00
![alt text ](https://raw.githubusercontent.com/abidlabs/gradio/master/screenshots/mnist4.png )
2019-02-20 12:47:45 +08:00
#### Facial Emotion Detector (Input: Webcam, Output: Class)
2019-02-20 14:26:48 +08:00
```python
iface = gradio.Interface(input='webcam', output='class', model=model, model_type='keras')
iface.launch()
```
2019-02-20 14:24:29 +08:00
![alt text ](https://raw.githubusercontent.com/abidlabs/gradio/master/screenshots/webcam_happy.png )
2019-02-20 12:47:45 +08:00
#### Sentiment Analysis (Input: Textbox, Output: Class)
2019-02-20 14:26:48 +08:00
```python
iface = gradio.Interface(input='textbox', output='class', model=model, model_type='keras')
iface.launch()
```
2019-02-20 14:24:29 +08:00
![alt text ](https://raw.githubusercontent.com/abidlabs/gradio/master/screenshots/sentiment_positive.png )
2019-02-20 12:46:44 +08:00
2019-02-20 12:39:21 +08:00