panik's picture
Update app.py
3664c8f
raw
history blame
853 Bytes
import gradio as gr
import tensorflow as tf
import keras
from keras.datasets import mnist
import matplotlib.pyplot as plt
import random
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()
def get_digit(digit_choice):
rn = 0
while(test_labels[rn] != digit_choice):
rn = int(random.random() * 1000)
digit = train_images[rn]
fig = plt.figure()
plt.imshow(digit)
out_txt = "digit index: %d\ndigit label: %d" % digit_choice, rn
return fig, out_txt
iface = gr.Interface(
fn = get_digit,
#inputs='image',
#inputs=[gr.inputs.Image(label="Input Image", source="webcam")],
inputs = [
gr.inputs.Dropdown([0, 1, 2, 3])
#gr.inputs.Number()
#'text'
],
#outputs='image',
outputs=[gr.outputs.Image(type="plot"), 'text'],
title='page title',
description='page description'
)
iface.launch()