Spaces:
Sleeping
Sleeping
adding my files
Browse files- .gitattributes +1 -0
- app.py +34 -0
- c0-rock-IMG_20230225_171937.jpg +3 -0
- c0-rock-IMG_20230225_171940.jpg +3 -0
- c1-paper-IMG_20230225_172010.jpg +3 -0
- c1-paper-IMG_20230225_172018.jpg +3 -0
- c2-scissors-IMG_20230225_172025.jpg +3 -0
- c2-scissors-IMG_20230225_172033.jpg +3 -0
- requirements.txt +3 -0
- rock-paper-scissors-resnet34.pkl +3 -0
- rock-paper-scissors-squeezenet.pkl +3 -0
.gitattributes
CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
import pathlib, os
|
4 |
+
|
5 |
+
|
6 |
+
classes = ['rock', 'paper', 'scissors'] # c0, c1, c2
|
7 |
+
|
8 |
+
def classify_image(img, model):
|
9 |
+
if os.name == 'nt': # workaround for Windows
|
10 |
+
pathlib.PosixPath = pathlib.WindowsPath
|
11 |
+
if os.name == 'posix': # workaround for Linux
|
12 |
+
pathlib.WindowsPath = pathlib.PosixPath
|
13 |
+
|
14 |
+
learn = load_learner(model)
|
15 |
+
pred,idx,probs = learn.predict(img)
|
16 |
+
return dict(zip(classes, map(float, probs)))
|
17 |
+
|
18 |
+
models = ['rock-paper-scissors-squeezenet.pkl','rock-paper-scissors-resnet34.pkl']
|
19 |
+
model = gr.Dropdown(models, label="Select Model")
|
20 |
+
|
21 |
+
image = gr.inputs.Image(shape=(192,192))
|
22 |
+
label = gr.outputs.Label()
|
23 |
+
examples = [
|
24 |
+
['c0-rock-IMG_20230225_171937.jpg'],
|
25 |
+
['c0-rock-IMG_20230225_171940.jpg'],
|
26 |
+
['c1-paper-IMG_20230225_172010.jpg'],
|
27 |
+
['c1-paper-IMG_20230225_172018.jpg'],
|
28 |
+
['c2-scissors-IMG_20230225_172025.jpg'],
|
29 |
+
['c2-scissors-IMG_20230225_172033.jpg']
|
30 |
+
]
|
31 |
+
|
32 |
+
# iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
33 |
+
iface = gr.Interface(fn=classify_image, inputs=[image, model], outputs=label, examples=examples)
|
34 |
+
iface.launch()
|
c0-rock-IMG_20230225_171937.jpg
ADDED
Git LFS Details
|
c0-rock-IMG_20230225_171940.jpg
ADDED
Git LFS Details
|
c1-paper-IMG_20230225_172010.jpg
ADDED
Git LFS Details
|
c1-paper-IMG_20230225_172018.jpg
ADDED
Git LFS Details
|
c2-scissors-IMG_20230225_172025.jpg
ADDED
Git LFS Details
|
c2-scissors-IMG_20230225_172033.jpg
ADDED
Git LFS Details
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
torch
|
3 |
+
gradio
|
rock-paper-scissors-resnet34.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2cd76ad5e04de5d1057ea787ca9a2620c2c073eeb4fec8b8d64466df54fbbabb
|
3 |
+
size 87523036
|
rock-paper-scissors-squeezenet.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9520376833818d557b0c9028043bb84ea8c9d1a9dd34210f4071748d59761aed
|
3 |
+
size 5167991
|