yupikopi commited on
Commit
6bca7b8
1 Parent(s): 33c502a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -1,17 +1,19 @@
1
  import tensorflow as tf
2
- inception_net = tf.keras.applications.MobileNetV2()
3
 
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
 
@@ -20,4 +22,4 @@ import gradio as gr
20
 
21
  gr.Interface(fn=classify_image,
22
  inputs=gr.Image(shape=(224, 224)),
23
- outputs=gr.Label(num_top_classes=3)).launch()
 
1
  import tensorflow as tf
2
+ #inception_net = tf.keras.applications.MobileNetV2()
3
 
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
+ model.load("./Pikachu_and_Raichu.h5")
12
 
13
  def classify_image(inp):
14
  inp = inp.reshape((-1, 224, 224, 3))
15
+ inp = model(inp)
16
+ prediction = model(inp).flatten()
17
  confidences = {labels[i]: float(prediction[i]) for i in range(1000)}
18
  return confidences
19
 
 
22
 
23
  gr.Interface(fn=classify_image,
24
  inputs=gr.Image(shape=(224, 224)),
25
+ outputs=gr.Label(num_top_classes=2)).launch()