Spaces:
Runtime error
Runtime error
Debugin code
Browse files- app.py +9 -11
- requirements.txt +1 -2
app.py
CHANGED
|
@@ -4,16 +4,14 @@ from git import Repo
|
|
| 4 |
Repo.clone_from("https://github.com/dimitreOliveira/hub.git", "./hub")
|
| 5 |
sys.path.append("/hub")
|
| 6 |
|
| 7 |
-
import requests
|
| 8 |
-
# Download human-readable labels for ImageNet.
|
| 9 |
-
response = requests.get("https://storage.googleapis.com/download.tensorflow.org/data/ImageNetLabels.txt")
|
| 10 |
-
labels = [x for x in response.text.split("\n") if x != ""]
|
| 11 |
-
|
| 12 |
-
|
| 13 |
import gradio as gr
|
| 14 |
-
import tensorflow as tf
|
| 15 |
from hub.tensorflow_hub.hf_utils import pull_from_hub
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
model = pull_from_hub(repo_id="Dimitre/mobilenet_v3_small")
|
| 18 |
|
| 19 |
def preprocess(image):
|
|
@@ -25,14 +23,14 @@ def preprocess(image):
|
|
| 25 |
print(image / 255.)
|
| 26 |
return image / 255.
|
| 27 |
|
| 28 |
-
def postprocess(prediction):
|
| 29 |
-
|
| 30 |
|
| 31 |
def predict_fn(image):
|
| 32 |
image = preprocess(image)
|
| 33 |
prediction = model([image])
|
| 34 |
-
scores = postprocess(prediction)
|
| 35 |
-
return
|
| 36 |
|
| 37 |
iface = gr.Interface(fn=predict_fn,
|
| 38 |
inputs=gr.Image(shape=(224, 224)),
|
|
|
|
| 4 |
Repo.clone_from("https://github.com/dimitreOliveira/hub.git", "./hub")
|
| 5 |
sys.path.append("/hub")
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
import gradio as gr
|
|
|
|
| 8 |
from hub.tensorflow_hub.hf_utils import pull_from_hub
|
| 9 |
|
| 10 |
+
# import requests
|
| 11 |
+
# # Download human-readable labels for ImageNet.
|
| 12 |
+
# response = requests.get("https://storage.googleapis.com/download.tensorflow.org/data/ImageNetLabels.txt")
|
| 13 |
+
# labels = [x for x in response.text.split("\n") if x != ""]
|
| 14 |
+
|
| 15 |
model = pull_from_hub(repo_id="Dimitre/mobilenet_v3_small")
|
| 16 |
|
| 17 |
def preprocess(image):
|
|
|
|
| 23 |
print(image / 255.)
|
| 24 |
return image / 255.
|
| 25 |
|
| 26 |
+
# def postprocess(prediction):
|
| 27 |
+
# return {labels[i]: prediction[i] for i in range(len(labels))}
|
| 28 |
|
| 29 |
def predict_fn(image):
|
| 30 |
image = preprocess(image)
|
| 31 |
prediction = model([image])
|
| 32 |
+
# scores = postprocess(prediction)
|
| 33 |
+
return prediction
|
| 34 |
|
| 35 |
iface = gr.Interface(fn=predict_fn,
|
| 36 |
inputs=gr.Image(shape=(224, 224)),
|
requirements.txt
CHANGED
|
@@ -1,2 +1 @@
|
|
| 1 |
-
GitPython
|
| 2 |
-
tensorflow
|
|
|
|
| 1 |
+
GitPython
|
|
|