Spaces:
Build error
Build error
simple interface built
Browse files- aih_model.pkl +3 -0
- app.py +15 -8
- model_cm.png +0 -0
- samples/h1.jpg +0 -0
- samples/h2.jpg +0 -0
- samples/h3.jpg +0 -0
aih_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:60b6145a2a1c9b374b1c7b642c9847a3712c1b4693d77dedeb46a10160d0bcb6
|
| 3 |
+
size 46971755
|
app.py
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
return "Hey " +name+ "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
fn=greet,
|
| 8 |
-
inputs='text',
|
| 9 |
-
outputs='text'
|
| 10 |
-
)
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
+
from pathlib import Path
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
learn = load_learner('aih_model.pkl')
|
|
|
|
| 6 |
|
| 7 |
+
categories = ('AI Hand', 'Human Hand')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
def classify_image(img):
|
| 10 |
+
pred,idx,probs = learn.predict(img)
|
| 11 |
+
return dict(zip(categories, map(float,probs)))
|
| 12 |
+
|
| 13 |
+
image = gr.Image(shape=(512,512))
|
| 14 |
+
label = gr.Label()
|
| 15 |
+
examples = [str(x) for x in Path('./samples').glob('*')]
|
| 16 |
+
|
| 17 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label,
|
| 18 |
+
examples=examples)
|
| 19 |
+
intf.launch()
|
model_cm.png
ADDED
|
samples/h1.jpg
ADDED
|
samples/h2.jpg
ADDED
|
samples/h3.jpg
ADDED
|