demo changes

This commit is contained in:
Abubakar Abid 2021-09-16 16:16:49 -07:00
parent ae4307d3f0
commit c302dc56fa
29 changed files with 43 additions and 63 deletions

View File

@ -1,5 +1,3 @@
# Demo: (Textbox, Textbox) -> (HighlightedText)
import gradio as gr
from difflib import Differ

View File

@ -1,5 +1,3 @@
# Demo: (Image) -> (Label)
import tensorflow as tf
import gradio
import gradio as gr

View File

@ -1,5 +1,3 @@
# Demo: (Dataframe, Dropdown) -> (Dataframe)
import gradio as gr
def filter_records(records, gender):

View File

@ -1,5 +1,3 @@
# Demo: (Timeseries, CheckboxGroup, Slider) -> (Timeseries, Dataframe, Label)
import gradio as gr
import pandas as pd
import random

View File

@ -1,5 +1,3 @@
# Demo: (Dropdown, Slider, Textbox) -> (Audio)
import gradio as gr
import numpy as np

View File

@ -1,5 +1,3 @@
# Demo: (Image) -> (Label)
import gradio as gr
import tensorflow as tf
import numpy as np

View File

@ -1,5 +1,3 @@
# Demo: (Image) -> (Image)
import gradio as gr

View File

@ -1,5 +1,3 @@
# Demo: (Textbox) -> (Label)
import gradio as gr
def longest_word(text):

View File

@ -1,5 +1,3 @@
# Demo: (Audio) -> (Label)
import gradio as gr
import numpy as np
from scipy.fftpack import fft

View File

@ -1,5 +1,3 @@
# Demo: (Dataframe) -> (Dataframe)
import gradio as gr
import numpy as np

View File

@ -1,5 +1,3 @@
# Demo: (Audio) -> (Audio)
import gradio as gr
import numpy as np

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 KiB

View File

@ -1,5 +1,3 @@
# Demo: (Slider, Dropdown, Radio, CheckboxGroup, Checkbox) -> (Textbox)
import gradio as gr
def sentence_builder(quantity, animal, place, activity_list, morning):

View File

@ -1,5 +1,3 @@
# Demo: (Textbox) -> (Label)
import gradio as gr
import nltk
from nltk.sentiment.vader import SentimentIntensityAnalyzer

View File

@ -1,5 +1,3 @@
# Demo: (Audio) -> (Image)
import gradio as gr
import matplotlib.pyplot as plt
import numpy as np

View File

@ -1,5 +1,3 @@
# Demo: (Radio, CheckboxGroup, Slider, Checkbox, Dropdown) -> (Image)
import gradio as gr
import matplotlib.pyplot as plt
import numpy as np

View File

@ -1,5 +1,3 @@
# Demo: (Image) -> (Image)
import gradio as gr
def detect(image):

View File

@ -1,5 +1,3 @@
# Demo: (Number, Radio, Dataframe) -> (Textbox)
import gradio as gr
def tax_calculator(income, marital_status, assets):

View File

@ -1,5 +1,3 @@
# Demo: (Textbox) -> (HighlightedText, KeyValues, HTML)
import spacy
from spacy import displacy
import gradio as gr

View File

@ -1,5 +1,3 @@
# Demo: (Dropdown, Checkbox, Slider, CheckboxGroup, Number, Radio) -> (Label)
import pandas as pd
import numpy as np
import sklearn
@ -75,7 +73,7 @@ iface = gr.Interface(
"checkbox",
gr.inputs.Slider(0, 80),
gr.inputs.CheckboxGroup(["Sibling", "Child"], label="Travelling with (select all)"),
gr.inputs.Number().interpret(delta_type="absolute", delta=5),
gr.inputs.Number(),
gr.inputs.Radio(["S", "C", "Q"], type="index"),
],
"label",

View File

@ -22,12 +22,12 @@ def FCN(num_output=21, input_shape=(500, 500, 3)):
def _crop(target_layer, offset=(None, None), name=None):
"""Crop the bottom such that it has the same shape as target_layer."""
""" Use _keras_shape to prevent undefined output shape in Conv2DTranspose"""
""" Use shape to prevent undefined output shape in Conv2DTranspose"""
def f(x):
width = x._keras_shape[ROW_AXIS]
height = x._keras_shape[COL_AXIS]
target_width = target_layer._keras_shape[ROW_AXIS]
target_height = target_layer._keras_shape[COL_AXIS]
width = x.shape[ROW_AXIS]
height = x.shape[COL_AXIS]
target_width = target_layer.shape[ROW_AXIS]
target_height = target_layer.shape[COL_AXIS]
cropped = Cropping2D(cropping=((offset[0], width - offset[0] - target_width), (offset[1], height - offset[1] - target_height)), name='{}'.format(name))(x)
return cropped
return f

View File

@ -1,5 +1,3 @@
# Demo: (Video) -> (Image)
import gradio as gr

View File

@ -1,5 +1,3 @@
# Demo: (Image) -> (Image)
import gradio as gr
import numpy as np

View File

@ -1,5 +1,3 @@
# Demo: (File) -> (JSON)
import gradio as gr
from zipfile import ZipFile

View File

@ -1,5 +1,3 @@
# Demo: (File, File) -> (File)
import gradio as gr
from zipfile import ZipFile

View File

@ -1,4 +1,4 @@
Metadata-Version: 1.0
Metadata-Version: 2.1
Name: gradio
Version: 2.3.4
Summary: Python library for easily interacting with trained machine learning models

View File

@ -1,15 +1,15 @@
Flask-Cors>=3.0.8
Flask-Login
Flask>=1.1.1
analytics-python
ffmpy
flask-cachebuster
markdown2
matplotlib
numpy
scipy
matplotlib
pandas
paramiko
pillow
ffmpy
markdown2
pycryptodome
requests
scipy
paramiko
analytics-python
Flask>=1.1.1
Flask-Cors>=3.0.8
flask-cachebuster
Flask-Login

View File

@ -82,6 +82,7 @@ class Textbox(InputComponent):
"""
Component creates a textbox for user to enter input. Provides a string as an argument to the wrapped function.
Input type: str
Demos: hello_world.py, diff_texts.py
"""
def __init__(self, lines=1, placeholder=None, default="", numeric=False, type="str", label=None):
@ -214,6 +215,7 @@ class Number(InputComponent):
"""
Component creates a field for user to enter numeric input. Provides a nuber as an argument to the wrapped function.
Input type: float
Demos: tax_calculator.py, titanic_survival.py
"""
def __init__(self, default=None, label=None):
@ -294,6 +296,7 @@ class Slider(InputComponent):
"""
Component creates a slider that ranges from `minimum` to `maximum`. Provides a number as an argument to the wrapped function.
Input type: float
Demos: sentence_builder.py, generate_tone.py, titanic_survival.py
"""
def __init__(self, minimum=0, maximum=100, step=None, default=None, label=None):
@ -367,6 +370,7 @@ class Checkbox(InputComponent):
"""
Component creates a checkbox that can be set to `True` or `False`. Provides a boolean as an argument to the wrapped function.
Input type: bool
Demos: sentence_builder.py, titanic_survival.py
"""
def __init__(self, default=False, label=None):
@ -427,6 +431,7 @@ class CheckboxGroup(InputComponent):
"""
Component creates a set of checkboxes of which a subset can be selected. Provides a list of strings representing the selected choices as an argument to the wrapped function.
Input type: Union[List[str], List[int]]
Demos: sentence_builder.py, titanic_survival.py, fraud_detector.py
"""
def __init__(self, choices, default=[], type="value", label=None):
@ -512,6 +517,7 @@ class Radio(InputComponent):
"""
Component creates a set of radio buttons of which only one can be selected. Provides string representing selected choice as an argument to the wrapped function.
Input type: Union[str, int]
Demos: sentence_builder.py, tax_calculator.py, titanic_survival.py
"""
def __init__(self, choices, type="value", default=None, label=None):
@ -576,6 +582,7 @@ class Dropdown(InputComponent):
"""
Component creates a dropdown of which only one can be selected. Provides string representing selected choice as an argument to the wrapped function.
Input type: Union[str, int]
Demos: sentence_builder.py, filter_records.py, titanic_survival.py
"""
def __init__(self, choices, type="value", default=None, label=None):
@ -640,6 +647,7 @@ class Image(InputComponent):
"""
Component creates an image upload box with editing capabilities.
Input type: Union[numpy.array, PIL.Image, file-object]
Demos: image_classifier.py, image_mod.py, webcam.py, digit_classifier.py
"""
def __init__(self, shape=None, image_mode='RGB', invert_colors=False, source="upload", tool="editor", type="numpy", label=None, optional=False):
@ -820,6 +828,7 @@ class Video(InputComponent):
"""
Component creates a video file upload that is converted to a file path.
Input type: filepath
Demos: video_flip.py
"""
def __init__(self, type="avi", label=None, optional=False):
@ -873,6 +882,7 @@ class Audio(InputComponent):
"""
Component accepts audio input files.
Input type: Union[Tuple[int, numpy.array], file-object, numpy.array]
Demos: main_note.py, reverse_audio.py, spectogram.py
"""
def __init__(self, source="upload", type="numpy", label=None, optional=False):
@ -1022,6 +1032,7 @@ class File(InputComponent):
"""
Component accepts generic file uploads.
Input type: Union[file-object, bytes, List[Union[file-object, bytes]]]
Demos: zip_to_json.py, zip_two_files.py
"""
def __init__(self, file_count="single", type="file", label=None, keep_filename=True, optional=False):
@ -1098,6 +1109,7 @@ class Dataframe(InputComponent):
"""
Component accepts 2D input through a spreadsheet interface.
Input type: Union[pandas.DataFrame, numpy.array, List[Union[str, float]], List[List[Union[str, float]]]]
Demos: filter_records.py, matrix_transpose.py, tax_calculator.py
"""
def __init__(self, headers=None, row_count=3, col_count=3, datatype="str", col_width=None, default=None, type="pandas", label=None):
@ -1178,6 +1190,7 @@ class Timeseries(InputComponent):
"""
Component accepts pandas.DataFrame uploaded as a timeseries csv file.
Input type: pandas.DataFrame
Demos: fraud_detector.py
"""
def __init__(self, x=None, y=None, label=None):

View File

@ -36,6 +36,7 @@ class Textbox(OutputComponent):
'''
Component creates a textbox to render output text or number.
Output type: Union[str, float, int]
Demos: hello_world.py, sentence_builder.py
'''
def __init__(self, type="auto", label=None):
@ -73,6 +74,7 @@ class Label(OutputComponent):
'''
Component outputs a classification label, along with confidence scores of top categories if provided. Confidence scores are represented as a dictionary mapping labels to scores between 0 and 1.
Output type: Union[Dict[str, float], str, int, float]
Demos: image_classifier.py, main_note.py, titanic_survival.py
'''
CONFIDENCES_KEY = "confidences"
@ -138,6 +140,7 @@ class Image(OutputComponent):
'''
Component displays an output image.
Output type: Union[numpy.array, PIL.Image, str, matplotlib.pyplot, Tuple[Union[numpy.array, PIL.Image, str], List[Tuple[str, float, float, float, float]]]]
Demos: image_mod.py, webcam.py
'''
def __init__(self, type="auto", labeled_segments=False, plot=False, label=None):
@ -206,6 +209,7 @@ class Video(OutputComponent):
'''
Used for video output.
Output type: filepath
Demos: video_flip.py
'''
def __init__(self, label=None):
@ -235,6 +239,7 @@ class KeyValues(OutputComponent):
'''
Component displays a table representing values for multiple fields.
Output type: Union[Dict, List[Tuple[str, Union[str, int, float]]]]
Demos: text_analysis.py
'''
def __init__(self, label=None):
@ -271,6 +276,7 @@ class HighlightedText(OutputComponent):
Component creates text that contains spans that are highlighted by category or numerical value.
Output is represent as a list of Tuple pairs, where the first element represents the span of text represented by the tuple, and the second element represents the category or value of the text.
Output type: List[Tuple[str, Union[float, str]]]
Demos: diff_texts.py, text_analysis.py
'''
def __init__(self, color_map=None, label=None):
@ -308,6 +314,7 @@ class Audio(OutputComponent):
'''
Creates an audio player that plays the output audio.
Output type: Union[Tuple[int, numpy.array], str]
Demos: generate_tone.py, reverse_audio.py
'''
def __init__(self, type="auto", label=None):
@ -351,6 +358,7 @@ class JSON(OutputComponent):
'''
Used for JSON output. Expects a JSON string or a Python object that is JSON serializable.
Output type: Union[str, Any]
Demos: zip_to_json.py
'''
def __init__(self, label=None):
@ -384,6 +392,7 @@ class HTML(OutputComponent):
'''
Used for HTML output. Expects an HTML valid string.
Output type: str
Demos: text_analysis.py
'''
def __init__(self, label=None):
@ -405,6 +414,7 @@ class File(OutputComponent):
'''
Used for file output.
Output type: Union[file-like, str]
Demos: zip_two_files.py
'''
def __init__(self, label=None):
@ -439,6 +449,7 @@ class Dataframe(OutputComponent):
"""
Component displays 2D output through a spreadsheet interface.
Output type: Union[pandas.DataFrame, numpy.array, List[Union[str, float]], List[List[Union[str, float]]]]
Demos: filter_records.py, matrix_transpose.py, fraud_detector.py
"""
def __init__(self, headers=None, max_rows=20, max_cols=None, overflow_row_behaviour="paginate", type="auto", label=None):
@ -512,6 +523,7 @@ class Carousel(OutputComponent):
"""
Component displays a set of output components that can be scrolled through.
Output type: List[List[Any]]
Demos: disease_report.py
"""
def __init__(self, components, label=None):
@ -571,6 +583,7 @@ class Timeseries(OutputComponent):
"""
Component accepts pandas.DataFrame.
Output type: pandas.DataFrame
Demos: fraud_detector.py
"""
def __init__(self, x=None, y=None, label=None):