Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,10 +4,8 @@ import skimage
|
|
4 |
|
5 |
learn = load_learner('model.pkl')
|
6 |
|
7 |
-
# Original labels from the model
|
8 |
labels = learn.dls.vocab
|
9 |
|
10 |
-
# Custom mapping for labels
|
11 |
custom_labels = {
|
12 |
"Other": "Nimeshindwa kutambua picha",
|
13 |
"lateblt": "Ukungu wa mwisho wa viazi",
|
@@ -18,13 +16,11 @@ custom_labels = {
|
|
18 |
def predict(img):
|
19 |
img = PILImage.create(img)
|
20 |
pred, pred_idx, probs = learn.predict(img)
|
21 |
-
# Map the model's labels to the custom labels
|
22 |
return {custom_labels[labels[i]]: float(probs[i]) for i in range(len(labels))}
|
23 |
|
24 |
-
# Other parameters
|
25 |
examples = ['image.jpg']
|
26 |
interpretation = 'default'
|
27 |
enable_queue = True
|
28 |
|
29 |
-
#
|
30 |
-
gr.Interface(fn=predict, inputs=gr.
|
|
|
4 |
|
5 |
learn = load_learner('model.pkl')
|
6 |
|
|
|
7 |
labels = learn.dls.vocab
|
8 |
|
|
|
9 |
custom_labels = {
|
10 |
"Other": "Nimeshindwa kutambua picha",
|
11 |
"lateblt": "Ukungu wa mwisho wa viazi",
|
|
|
16 |
def predict(img):
|
17 |
img = PILImage.create(img)
|
18 |
pred, pred_idx, probs = learn.predict(img)
|
|
|
19 |
return {custom_labels[labels[i]]: float(probs[i]) for i in range(len(labels))}
|
20 |
|
|
|
21 |
examples = ['image.jpg']
|
22 |
interpretation = 'default'
|
23 |
enable_queue = True
|
24 |
|
25 |
+
# Updated component usage
|
26 |
+
gr.Interface(fn=predict, inputs=gr.Image(shape=(512, 512)), outputs=gr.Label(num_top_classes=3), examples=examples, interpretation=interpretation, enable_queue=enable_queue).launch()
|