anatexis
commited on
Commit
•
013c1cb
1
Parent(s):
2a7146c
update .gitattributes so git lfs will track .pkl files
Browse files
app.py
CHANGED
@@ -1,7 +1,25 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
|
5 |
+
learn = load_learner('export.pkl')
|
|
|
6 |
|
7 |
+
categories = ('Lego Ninjago','Lego (non Ninjago)')
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
+
def predict(img):
|
12 |
+
img = PILImage.create(img)
|
13 |
+
pred, pred_idx, probs = learn.predict(img)
|
14 |
+
return dict(zip(categories, map(float,probs)))
|
15 |
+
|
16 |
+
|
17 |
+
title = "Lego Classifier"
|
18 |
+
description = "Classifies Lego into 'Ninjago' and 'Non Ninjago' with fastai. Created from the fastai demo for Gradio and HuggingFace Spaces."
|
19 |
+
#article = "<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
|
20 |
+
examples = ['ninjago.jpg', 'lego_nn.jpg']
|
21 |
+
interpretation = 'default'
|
22 |
+
enable_queue = True
|
23 |
+
|
24 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=2), title=title,
|
25 |
+
description=description, examples=examples, interpretation=interpretation, enable_queue=enable_queue).launch()
|