Spaces:
Runtime error
Runtime error
amr.malik
commited on
Commit
·
4cff171
1
Parent(s):
34bec45
add app.py etc.
Browse files- app.py +22 -0
- beard_00000111.jpg +0 -0
- beard_00000119.jpg +0 -0
- beard_00000129.jpg +0 -0
- beard_00000162.jpg +0 -0
- clean_00000115.jpg +0 -0
- clean_00000138.jpeg +0 -0
- clean_00000197.jpg +0 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# The A.M.A.Z.I.N.G B.E.A.R.D D.E.T.E.C.T.I.V.E ! ! !
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
from fastai.vision.all import *
|
5 |
+
import skimage
|
6 |
+
|
7 |
+
learn = load_learner('export.pkl')
|
8 |
+
|
9 |
+
labels = learn.dls.vocab
|
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 |
+
title = "The A.M.A.Z.I.N.G B.E.A.R.D D.E.T.E.C.T.I.V.E ! ! !"
|
16 |
+
description = "A Beard Detector created using a pretrained ResNet50 model fine tuned using fast.ai"
|
17 |
+
article="<p style='text-align: center'><a href='https://www.kaggle.com/code/mikemoloch/the-amazing-beard-detector' target='_blank'>Kaggle Notebook</a></p>"
|
18 |
+
examples = [ 'beard_00000111.jpg', 'beard_00000119.jpg', 'beard_00000129.jpg', 'beard_00000162.jpg', 'clean_00000115.jpg', 'clean_00000138.jpeg', 'clean_00000197.jpg' ]
|
19 |
+
interpretation='default'
|
20 |
+
enable_queue=True
|
21 |
+
|
22 |
+
gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
|
beard_00000111.jpg
ADDED
![]() |
beard_00000119.jpg
ADDED
![]() |
beard_00000129.jpg
ADDED
![]() |
beard_00000162.jpg
ADDED
![]() |
clean_00000115.jpg
ADDED
![]() |
clean_00000138.jpeg
ADDED
![]() |
clean_00000197.jpg
ADDED
![]() |
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|