Spaces:
Runtime error
Runtime error
Arun Prakash
commited on
Commit
•
a401776
1
Parent(s):
c4916c3
add
Browse files- app.py +40 -0
- conf.jpeg +0 -0
- export_facecount.pkl +3 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
|
4 |
+
|
5 |
+
def get_headcount(filename):
|
6 |
+
#print(filename)
|
7 |
+
filename = str(filename)
|
8 |
+
filename = filename.split("/")[-1]
|
9 |
+
return df[df["Name"]==filename]["HeadCount"].values[0]
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
learn = load_learner("export_facecount.pkl")
|
14 |
+
|
15 |
+
# labels = learn.dls.vocab
|
16 |
+
|
17 |
+
|
18 |
+
def predict(img):
|
19 |
+
img = PILImage.create(img)
|
20 |
+
op = learn.predict(img)
|
21 |
+
return int(op[0][0])
|
22 |
+
|
23 |
+
|
24 |
+
title = "Face count"
|
25 |
+
description = "A Car or Bike or not classifier trained with downloaded data from internet. Created as a demo for Gradio and HuggingFace Spaces."
|
26 |
+
|
27 |
+
examples = ["conf.jpeg"]
|
28 |
+
interpretation = "default"
|
29 |
+
enable_queue = True
|
30 |
+
|
31 |
+
gr.Interface(
|
32 |
+
fn=predict,
|
33 |
+
inputs=gr.inputs.Image(shape=(512, 512)),
|
34 |
+
outputs=gr.outputs.Textbox(type="number", label="Number of faces"),
|
35 |
+
title=title,
|
36 |
+
description=description,
|
37 |
+
examples=examples,
|
38 |
+
interpretation=interpretation,
|
39 |
+
enable_queue=enable_queue,
|
40 |
+
).launch(share=False)
|
conf.jpeg
ADDED
![]() |
export_facecount.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5efe5147266f9987fb611afa32cf842ce7c989cb6be08ea17ac66c1d4b7855bf
|
3 |
+
size 47044205
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
|