# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# + id="NidqB07kxzgW"
from fastai.vision.all import *
from fastai.vision.widgets import *

# + id="bhysZr6pgtzN"
# #!jupyter serverextension enable voila --user
# #!jupyter serverextension enable voila --sys-prefix

# + [markdown] id="WwsRqMnYNxmO"
# # **Application for Yoga Pose Classification**
#  #### This is a project created to detect your Yoga Pose, It can classify total 10 Poses and you can know which asana you are doing. 
#  

# + id="DCIkndfxyh1P"
path = Path()
learn_inf = load_learner(path/'export.pkl',cpu=True)
btn_upload = widgets.FileUpload()
out_pl = widgets.Output()
lbl_pred = widgets.Label()


# + id="cODFq2mQyn2u"
def on_click(change):
    img = PILImage.create(btn_upload.data[-1])
    out_pl.clear_output()
    with out_pl: display(img.to_thumb(128,128))
    pred,pred_idx,probs = learn_inf.predict(img)
    lbl_pred.value = f'Prediction: {pred}; Probability: {probs[pred_idx]:.04f}'


# + id="Bktja4bA0psW"
btn_upload.observe(on_click, names=['data'])

# + colab={"base_uri": "https://localhost:8080/", "height": 113, "referenced_widgets": ["18e48ac84fd147e386f0638124784d1f", "<KEY>", "ffa522e2ed1d4f6ca7a1c8056f3ffa32", "c5337cc135874e4b89fea7c78803dd2b", "<KEY>", "2bf3115f62b949e6896a25d53077e592", "64e62115b82e4f9f88b920cbe538c3da", "<KEY>", "<KEY>", "60ba0656c17c449c8260789772083cf9", "<KEY>", "<KEY>", "<KEY>"]} id="ivPtOdlIy80Z" outputId="bbb58ddf-9b5b-4d92-fa3b-fffae7e5a6d2"
display(VBox([widgets.Label('Upload an image of your Yoga Pose to know the asana'), btn_upload,out_pl, lbl_pred]))

# + id="cmKSUBHbap8h"
# #!pip install voila
# #!jupyter serverextension enable --sys-prefix voila
# -



StarcoderdataJupyterScriptsDedupFiltered