Spaces:
Runtime error
Runtime error
Adding exmaples
Browse files- app.py +3 -7
- apples.jpeg +0 -0
- banana.jpeg +0 -0
- car.jpeg +0 -0
app.py
CHANGED
@@ -15,12 +15,7 @@ labels = [x for x in response.text.split("\n") if x != ""]
|
|
15 |
model = pull_from_hub(repo_id="Dimitre/mobilenet_v3_small")
|
16 |
|
17 |
def preprocess(image):
|
18 |
-
print(image)
|
19 |
-
print("***********")
|
20 |
image = image.reshape((-1, 224, 224, 3))
|
21 |
-
print(image)
|
22 |
-
print("***********")
|
23 |
-
print(image / 255.)
|
24 |
return image / 255.
|
25 |
|
26 |
def postprocess(prediction):
|
@@ -28,11 +23,12 @@ def postprocess(prediction):
|
|
28 |
|
29 |
def predict_fn(image):
|
30 |
image = preprocess(image)
|
31 |
-
prediction = model(
|
32 |
scores = postprocess(prediction)
|
33 |
return scores
|
34 |
|
35 |
iface = gr.Interface(fn=predict_fn,
|
36 |
inputs=gr.Image(shape=(224, 224)),
|
37 |
-
outputs=gr.Label(num_top_classes=5)
|
|
|
38 |
iface.launch()
|
|
|
15 |
model = pull_from_hub(repo_id="Dimitre/mobilenet_v3_small")
|
16 |
|
17 |
def preprocess(image):
|
|
|
|
|
18 |
image = image.reshape((-1, 224, 224, 3))
|
|
|
|
|
|
|
19 |
return image / 255.
|
20 |
|
21 |
def postprocess(prediction):
|
|
|
23 |
|
24 |
def predict_fn(image):
|
25 |
image = preprocess(image)
|
26 |
+
prediction = model(image)
|
27 |
scores = postprocess(prediction)
|
28 |
return scores
|
29 |
|
30 |
iface = gr.Interface(fn=predict_fn,
|
31 |
inputs=gr.Image(shape=(224, 224)),
|
32 |
+
outputs=gr.Label(num_top_classes=5),
|
33 |
+
examples=["apples.jpeg", "banana.jpeg", "car.jpeg"])
|
34 |
iface.launch()
|
apples.jpeg
ADDED
![]() |
banana.jpeg
ADDED
![]() |
car.jpeg
ADDED
![]() |