include demos as documentation
@ -1,3 +1,5 @@
|
||||
# Demo: (Textbox, Textbox) -> (HighlightedText)
|
||||
|
||||
import gradio as gr
|
||||
from difflib import Differ
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Demo: (Image) -> (Label)
|
||||
|
||||
import tensorflow as tf
|
||||
import gradio
|
||||
import os
|
||||
@ -16,7 +18,7 @@ def recognize_digit(image):
|
||||
|
||||
gr.Interface(
|
||||
recognize_digit,
|
||||
gradio.inputs.Image(shape=(28, 28), image_mode="L", source="canvas"),
|
||||
"sketchpad",
|
||||
gradio.outputs.Label(num_top_classes=3),
|
||||
live=True,
|
||||
capture_session=True,
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Demo (Dataframe, Dropdown) -> (Dataframe)
|
||||
|
||||
import gradio as gr
|
||||
import numpy as np
|
||||
import random
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Demo: (Dropdown, Slider, Textbox) -> (Audio)
|
||||
|
||||
import gradio as gr
|
||||
import numpy as np
|
||||
import random
|
||||
@ -8,6 +10,7 @@ def generate_tone(note, octave, duration):
|
||||
sr = 48000
|
||||
a4_freq, tones_from_a4 = 440, 12 * (octave - 4) + (note - 9)
|
||||
frequency = a4_freq * 2 ** (tones_from_a4 / 12)
|
||||
duration = int(duration)
|
||||
audio = np.linspace(0, duration, duration * sr)
|
||||
audio = (20000 * np.sin(audio * (2 * np.pi * frequency))).astype(np.int16)
|
||||
return (sr, audio)
|
||||
|
@ -1,18 +1,17 @@
|
||||
# Demo: (Image) -> (Image)
|
||||
|
||||
import gradio as gr
|
||||
from time import time
|
||||
from PIL import Image, ImageFilter
|
||||
from PIL import Image
|
||||
|
||||
|
||||
def image_mod(image):
|
||||
return image.rotate(45), image.filter(ImageFilter.FIND_EDGES)
|
||||
return image.rotate(45)
|
||||
|
||||
|
||||
gr.Interface(image_mod,
|
||||
gr.inputs.Image(type="pil"),
|
||||
[
|
||||
gr.outputs.Image(type="pil"),
|
||||
gr.outputs.Image(type="pil"),
|
||||
],
|
||||
gr.outputs.Image(type="pil"),
|
||||
examples=[
|
||||
["images/cheetah1.jpg"],
|
||||
["images/cheetah2.jpg"],
|
||||
|
@ -1,9 +1,10 @@
|
||||
# Demo: (Dataframe) -> (Dataframe)
|
||||
|
||||
import gradio as gr
|
||||
import numpy as np
|
||||
import random
|
||||
|
||||
def transpose(matrix):
|
||||
print(matrix)
|
||||
return matrix.T
|
||||
|
||||
gr.Interface(transpose,
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Demo: (Audio) -> (Audio)
|
||||
|
||||
import gradio as gr
|
||||
import numpy as np
|
||||
import random
|
||||
|
BIN
demo/screenshots/diff_texts/1.png
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
demo/screenshots/digit_classifier/1.png
Normal file
After Width: | Height: | Size: 102 KiB |
BIN
demo/screenshots/digit_classifier/2.png
Normal file
After Width: | Height: | Size: 93 KiB |
BIN
demo/screenshots/filter_records/1.png
Normal file
After Width: | Height: | Size: 104 KiB |
BIN
demo/screenshots/generate_tone/1.png
Normal file
After Width: | Height: | Size: 108 KiB |
BIN
demo/screenshots/image_mod/1.png
Normal file
After Width: | Height: | Size: 1.4 MiB |
BIN
demo/screenshots/matrix_transpose/1.png
Normal file
After Width: | Height: | Size: 69 KiB |
BIN
demo/screenshots/reverse_audio/1.png
Normal file
After Width: | Height: | Size: 79 KiB |
BIN
demo/screenshots/reverse_audio/2.png
Normal file
After Width: | Height: | Size: 97 KiB |
BIN
demo/screenshots/sentence_builder/1.png
Normal file
After Width: | Height: | Size: 144 KiB |
BIN
demo/screenshots/spectogram/1.png
Normal file
After Width: | Height: | Size: 512 KiB |
BIN
demo/screenshots/stock_forecast/1.png
Normal file
After Width: | Height: | Size: 167 KiB |
BIN
demo/screenshots/text_analysis/1.png
Normal file
After Width: | Height: | Size: 169 KiB |
BIN
demo/screenshots/webcam.py/1.png
Normal file
After Width: | Height: | Size: 800 KiB |
BIN
demo/screenshots/zip_to_json/1.png
Normal file
After Width: | Height: | Size: 124 KiB |
BIN
demo/screenshots/zip_two_files/1.png
Normal file
After Width: | Height: | Size: 90 KiB |
@ -1,3 +1,5 @@
|
||||
# Demo: (Slider, Dropdown, Radio, CheckboxGroup, Checkbox) -> (Textbox)
|
||||
|
||||
import gradio as gr
|
||||
import numpy as np
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Demo: (Audio) -> (Image)
|
||||
|
||||
import gradio as gr
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
@ -5,13 +7,12 @@ from scipy import signal
|
||||
from scipy.io import wavfile
|
||||
|
||||
|
||||
def reverse_audio(audio):
|
||||
def spectrogram(audio):
|
||||
sr, data = audio
|
||||
data = np.delete(data, 1, 1).reshape(-1)
|
||||
frequencies, times, spectrogram = signal.spectrogram(data.reshape(-1), sr, window="hamming")
|
||||
|
||||
plt.pcolormesh(times, frequencies, np.log10(spectrogram))
|
||||
frequencies, times, spectrogram_data = signal.spectrogram(data.reshape(-1), sr, window="hamming")
|
||||
plt.pcolormesh(times, frequencies, np.log10(spectrogram_data))
|
||||
return plt
|
||||
|
||||
|
||||
gr.Interface(reverse_audio, "audio", "plot").launch()
|
||||
gr.Interface(spectrogram, "audio", "plot").launch()
|
||||
|
@ -1,3 +1,5 @@
|
||||
# (Radio, CheckboxGroup, Slider, Dropdown) -> (Image)
|
||||
|
||||
import gradio as gr
|
||||
import random
|
||||
import matplotlib.pyplot as plt
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Demo: (Textbox) -> (HighlightedText, KeyValues, HTML)
|
||||
|
||||
import spacy
|
||||
from spacy import displacy
|
||||
import gradio as gr
|
||||
|