abirmunna commited on
Commit
5696bb8
1 Parent(s): 64c2a3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -1,20 +1,28 @@
1
- import tensorflow as tf
2
  import requests
3
- import gradio as gr
4
 
5
  inception_net = tf.keras.applications.MobileNetV2()
6
 
 
 
 
7
  response = requests.get("https://git.io/JJkYN")
8
  labels = response.text.split("\n")
9
 
 
10
  def classify_image(inp):
11
  inp = inp.reshape((-1, 224, 224, 3))
12
  inp = tf.keras.applications.mobilenet_v2.preprocess_input(inp)
13
  prediction = inception_net.predict(inp).flatten()
14
  confidences = {labels[i]: float(prediction[i]) for i in range(1000)}
15
  return confidences
 
 
 
16
 
17
- interface = gr.Interface(fn=classify_image,
18
  inputs=gr.inputs.Image(shape=(224, 224)),
19
- outputs=gr.outputs.Label(num_top_classes=3))
20
- interface.launch()
 
 
 
 
1
  import requests
2
+ import tensorflow as tf
3
 
4
  inception_net = tf.keras.applications.MobileNetV2()
5
 
6
+ import requests
7
+
8
+ # Download human-readable labels for ImageNet.
9
  response = requests.get("https://git.io/JJkYN")
10
  labels = response.text.split("\n")
11
 
12
+
13
  def classify_image(inp):
14
  inp = inp.reshape((-1, 224, 224, 3))
15
  inp = tf.keras.applications.mobilenet_v2.preprocess_input(inp)
16
  prediction = inception_net.predict(inp).flatten()
17
  confidences = {labels[i]: float(prediction[i]) for i in range(1000)}
18
  return confidences
19
+
20
+
21
+ import gradio as gr
22
 
23
+ gr.Interface(fn=classify_image,
24
  inputs=gr.inputs.Image(shape=(224, 224)),
25
+ outputs=gr.outputs.Label(num_top_classes=3),
26
+ examples=["banana.jpg", "car.jpg"],
27
+ theme="default",
28
+ css=".footer{display:none !important}").launch()