Spaces:
Runtime error
Runtime error
File size: 1,421 Bytes
637dd18 016d6f4 637dd18 95295f6 637dd18 |
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 |
import pandas as pd
import pycaret
from pycaret.classification import *
import gradio as gr
model = load_model('ML_Model_Size_Frames')
load_config('ML_Model_Size_Frames_config')
def ml_classication(Height,Working_Distance,IPD_Infinity,IPD_WD,IPD_300mm):
columns = ['Frame_Size_Refractives','Height','Working_Distance','IPD_Infinity','IPD_WD','IPD_300mm']
df = pd.DataFrame(columns=columns)
df = df.append({'Height':Height,
'Working_Distance': Working_Distance, 'IPD_Infinity': IPD_Infinity,
'IPD_WD':IPD_WD, 'IPD_300mm': IPD_300mm}, ignore_index=True)
new_prediction = predict_model(model, data=df)
prediction = new_prediction['Label'].iloc[0]
score = new_prediction['Score'].iloc[0]
#
return prediction, score
inputs = [
gr.Slider(120, 220, 175, label="Height [cm]"),
gr.Slider(400, 600, 300, label="Working Distance [mm]"),
gr.Slider(45, 100, 60, label='IPD Infinity [mm]'),
gr.Slider(45, 100, 60, label="IPD Working Distance [mm]"),
gr.Slider(45, 100, 60, label="IPD 300 mm [mm]"),
]
outputs = [
gr.Text(label='Frame Size'),
gr.Text(label = 'Score'),
]
demo = gr.Interface(
fn=ml_classication,
inputs=inputs,
outputs=outputs,
examples=[
[163, 490, 62.0, 58.0, 56.0],
[180, 510, 63.5, 59.5, 57.5],
],
cache_examples=True,
)
if __name__ == "__main__":
demo.launch()
|