Spaces:
Sleeping
Sleeping
File size: 920 Bytes
7fa0587 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
#!/usr/bin/env python
# coding: utf-8
# In[1]:
from fastai.vision.all import *
import gradio as gr
import os
# In[ ]:
from pathlib import Path
from fastcore.xtras import Path
from fastai.learner import load_learner
from fastcore.foundation import L
# In[2]:
img_path = Path('./static')
images_lis = [ i for i in list(img_path.ls()) if i.is_file()]
images_lis[:3], len(images_lis)
# In[3]:
def label_to_class(f:str)->L:
return L(f)
# In[4]:
learner = load_learner('./model/asl_sign_multi_resnet18_03.pkl')
# In[ ]:
def pred_image(image):
dict = {}
for i, j in zip(learner.dls.vocab, learner.predict(image)[2]):
dict[i] = round(j.item(), 2)
return dict
demo = gr.Interface(
fn=pred_image,
inputs='image',
outputs=gr.Label(num_top_classes=29),
examples=images_lis,
)
if __name__ == "__main__":
demo.launch(debug=True)
# In[ ]:
# In[ ]:
|