Spaces:
Runtime error
Runtime error
Commit ·
89e0eb8
1
Parent(s): 9c4c3c4
test
Browse files
app.py
CHANGED
|
@@ -1,24 +1,18 @@
|
|
| 1 |
-
__all__ = ['models', 'image', 'label', 'examples', 'intf']
|
| 2 |
-
|
| 3 |
import gradio as gr
|
| 4 |
from fastai.vision.all import load_learner
|
| 5 |
|
| 6 |
-
|
| 7 |
-
load_learner('model-color.pkl')
|
| 8 |
-
|
| 9 |
-
|
| 10 |
|
| 11 |
-
def
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
pred, idx, probs = learn.predict(img)
|
| 16 |
-
results[f'model{i+1}'] = dict(zip(categories, map(float,probs)))
|
| 17 |
-
return results
|
| 18 |
|
| 19 |
image = gr.inputs.Image(shape=(256, 256))
|
| 20 |
-
label = gr.outputs.Label()
|
| 21 |
-
examples = []
|
| 22 |
|
| 23 |
-
intf = gr.Interface(fn=
|
| 24 |
-
intf.launch(
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from fastai.vision.all import load_learner
|
| 3 |
|
| 4 |
+
def classify_image_color(img):
|
| 5 |
+
learn_color = load_learner('lego-bricks-detecter-model-color.pkl')
|
| 6 |
+
pred,_,probs = learn_color.predict(img)
|
| 7 |
+
return dict(zip(learn_color.dls.vocab, map(float,probs)))
|
| 8 |
|
| 9 |
+
def classify_image_shape(img):
|
| 10 |
+
learn_shape = load_learner('lego-bricks-detecter-model-shape.pkl')
|
| 11 |
+
pred,_,probs = learn_shape.predict(img)
|
| 12 |
+
return dict(zip(learn_shape.dls.vocab, map(float,probs)))
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
image = gr.inputs.Image(shape=(256, 256))
|
| 15 |
+
label = gr.outputs.Label(num_top_classes=3)
|
|
|
|
| 16 |
|
| 17 |
+
intf = gr.Interface(fn=[classify_image_color, classify_image_shape], inputs=image, outputs=label, examples="", title="Lego Brick Classifier", layout="vertical")
|
| 18 |
+
intf.launch(share=True)
|