Spaces:
Sleeping
Sleeping
Commit
·
e49db51
1
Parent(s):
4b1cda0
Update app.py
Browse files
app.py
CHANGED
@@ -4,9 +4,12 @@ import skimage as sk
|
|
4 |
|
5 |
learn = load_learner('export.pkl')
|
6 |
labels = learn.dls.vocab
|
|
|
|
|
|
|
7 |
def predict(img):
|
8 |
img = PILImage.create(img)
|
9 |
pred,pred_idx,probs = learn.predict(img)
|
10 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
11 |
|
12 |
-
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)
|
|
|
4 |
|
5 |
learn = load_learner('export.pkl')
|
6 |
labels = learn.dls.vocab
|
7 |
+
EXAMPLES_PATH = Path('./examples')
|
8 |
+
examples = [f'{EXAMPLES_PATH}/{f.name}' for f in EXAMPLES_PATH.iterdir()]
|
9 |
+
|
10 |
def predict(img):
|
11 |
img = PILImage.create(img)
|
12 |
pred,pred_idx,probs = learn.predict(img)
|
13 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
14 |
|
15 |
+
gr.Interface(fn=predict, examples=examples, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)
|