iain maitland
commited on
Commit
•
fba23ba
1
Parent(s):
8f63dfc
let's deploy to huggingface spaces
Browse files- app.py +14 -1
- requirements.txt +2 -0
app.py
CHANGED
@@ -1,2 +1,15 @@
|
|
1 |
from fastai.vision.all import *
|
2 |
-
learn = load_learner('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from fastai.vision.all import *
|
2 |
+
learn = load_learner('cig_detector_2.pkl')
|
3 |
+
|
4 |
+
labels = learn.dls.vocab
|
5 |
+
def predict(img):
|
6 |
+
img = PILImage.create(img)
|
7 |
+
pred,pred_idx,probs = learn.predict(img)
|
8 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
9 |
+
|
10 |
+
import gradio as gr
|
11 |
+
|
12 |
+
title = "Smoking Classifier"
|
13 |
+
description = "A smoking, not smoking classifier trained with fastai."
|
14 |
+
examples = ['smoking1.jpg', 'smoking2.jpg', 'not_smoking.jpg']
|
15 |
+
gr.Interface(title=title, description=description, examples=examples,fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)
|
requirements.txt
CHANGED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|