Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
import
|
2 |
import gradio
|
3 |
import requests
|
4 |
-
inception_net =
|
5 |
|
6 |
response = requests.get("https://git.io/JJkYN")
|
7 |
labels = response.text.split("\n")
|
8 |
|
9 |
def classify_image(inp):
|
10 |
inp = inp.reshape((-1, 224, 224, 3))
|
11 |
-
inp =
|
12 |
prediction = inception_net.predict(inp).flatten()
|
13 |
confidences = {labels[i]: float(prediction[i]) for i in range(1000)}
|
14 |
return confidences
|
|
|
1 |
+
from tensorflow import keras
|
2 |
import gradio
|
3 |
import requests
|
4 |
+
inception_net = keras.applications.MobileNetV2()
|
5 |
|
6 |
response = requests.get("https://git.io/JJkYN")
|
7 |
labels = response.text.split("\n")
|
8 |
|
9 |
def classify_image(inp):
|
10 |
inp = inp.reshape((-1, 224, 224, 3))
|
11 |
+
inp = keras.applications.mobilenet_v2.preprocess_input(inp)
|
12 |
prediction = inception_net.predict(inp).flatten()
|
13 |
confidences = {labels[i]: float(prediction[i]) for i in range(1000)}
|
14 |
return confidences
|