panik commited on
Commit
5d9b8be
·
1 Parent(s): ef1f4cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -10
app.py CHANGED
@@ -1,23 +1,29 @@
1
  import gradio as gr
2
- #import tensorflow as tf
3
- #import keras
 
 
 
 
4
 
5
  def get_digit(digit_choice):
6
- if(digit_choice == 1):
7
- return 'one'
8
- else:
9
- return 'not one'
10
 
11
- gr.Interface(
12
  fn = get_digit,
13
  #inputs='image',
14
  #inputs=[gr.inputs.Image(label="Input Image", source="webcam")],
15
  inputs = [
16
- gr.inputs.Dropdown([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), #type='index'),
17
  #gr.inputs.Number()
18
  #'text'
19
  ],
20
  #outputs='image',
21
- outputs='text',
22
  title='page title',
23
- description='page description').launch()
 
 
 
1
  import gradio as gr
2
+ import tensorflow as tf
3
+ import keras
4
+ from keras.datasets import mnist
5
+ import matplotlib.pyplot as plt
6
+
7
+ (train_images, train_labels), (test_images, test_labels) = mnist.load_data()
8
 
9
  def get_digit(digit_choice):
10
+ digit = train_images[digit_choice]
11
+ fig = plt.imshow(digit)
12
+ out_txt = "digit: %d" % digit_choice
13
+ return fig, out_txt
14
 
15
+ iface = gr.Interface(
16
  fn = get_digit,
17
  #inputs='image',
18
  #inputs=[gr.inputs.Image(label="Input Image", source="webcam")],
19
  inputs = [
20
+ gr.inputs.Dropdown([0, 1, 2, 3),
21
  #gr.inputs.Number()
22
  #'text'
23
  ],
24
  #outputs='image',
25
+ outputs=[gr.outputs.Image(type="plot"), 'text'],
26
  title='page title',
27
+ description='page description')
28
+
29
+ iface.launch()