Spaces:
Build error
Build error
Demo
Browse files- .gitignore +1 -0
- Pipfile +13 -0
- Pipfile.lock +0 -0
- app.py +32 -0
- model.pkl +3 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.idea
|
Pipfile
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[[source]]
|
2 |
+
url = "https://pypi.org/simple"
|
3 |
+
verify_ssl = true
|
4 |
+
name = "pypi"
|
5 |
+
|
6 |
+
[packages]
|
7 |
+
gradio = "*"
|
8 |
+
fastai = "*"
|
9 |
+
|
10 |
+
[dev-packages]
|
11 |
+
|
12 |
+
[requires]
|
13 |
+
python_version = "3.10"
|
Pipfile.lock
ADDED
The diff for this file is too large to render.
See raw diff
|
|
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from fastai.vision.core import PILImage
|
4 |
+
|
5 |
+
import fastai.vision.all as fav
|
6 |
+
import os
|
7 |
+
if os.name != 'posix':
|
8 |
+
print('Converting PosixPath to WindowsPath')
|
9 |
+
import pathlib
|
10 |
+
pathlib.PosixPath = pathlib.WindowsPath
|
11 |
+
|
12 |
+
def is_cat(x): return x[0].isupper() # Used by model
|
13 |
+
learn = fav.load_learner('model.pkl')
|
14 |
+
|
15 |
+
labels = learn.dls.vocab
|
16 |
+
|
17 |
+
def predict(img):
|
18 |
+
img = PILImage.create(img)
|
19 |
+
pred,pred_idx,probs = learn.predict(img)
|
20 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
21 |
+
|
22 |
+
iface = gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3))
|
23 |
+
|
24 |
+
iface.launch()
|
25 |
+
|
26 |
+
# def greet(name):
|
27 |
+
# return "Hello " + name + "!!"
|
28 |
+
#
|
29 |
+
# # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
30 |
+
#
|
31 |
+
# iface.launch()
|
32 |
+
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:790c9e9db9356628ebb2bda53ea99f22d0f5bf22b59dca34c0ce1399ff0da214
|
3 |
+
size 47065259
|