Spaces:
Build error
Build error
Commit
·
63fca82
1
Parent(s):
8c508e1
new app
Browse files
app.py
CHANGED
|
@@ -1,23 +1,17 @@
|
|
| 1 |
-
import
|
| 2 |
import tensorflow as tf
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
# Download human-readable labels for ImageNet.
|
| 7 |
-
response = requests.get("https://git.io/JJkYN")
|
| 8 |
-
labels = response.text.split("\n")
|
| 9 |
|
| 10 |
def classify_image(inp):
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
confidences = {labels[i]: float(prediction[i]) for i in range(1000)}
|
| 15 |
-
return confidences
|
| 16 |
|
| 17 |
|
| 18 |
-
import gradio as gr
|
| 19 |
-
|
| 20 |
gr.Interface(fn=classify_image,
|
| 21 |
inputs=gr.inputs.Image(shape=(224, 224)),
|
| 22 |
-
outputs=
|
| 23 |
-
examples=[
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
import tensorflow as tf
|
| 3 |
|
| 4 |
+
new_model = tf.keras.models.load_model('my_model.h5')
|
| 5 |
+
# preprocess_input = tf.keras.applications.resnet50.preprocess_input
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def classify_image(inp):
|
| 8 |
+
inp = inp.reshape((-1, 224, 224, 3))
|
| 9 |
+
prediction = new_model.predict(inp).flatten()
|
| 10 |
+
return prediction
|
|
|
|
|
|
|
| 11 |
|
| 12 |
|
|
|
|
|
|
|
| 13 |
gr.Interface(fn=classify_image,
|
| 14 |
inputs=gr.inputs.Image(shape=(224, 224)),
|
| 15 |
+
outputs="label",
|
| 16 |
+
examples=[]).launch()
|
| 17 |
+
|