chaninder commited on
Commit
d87cb47
1 Parent(s): 73e3e01

update app.py

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