Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from huggingface_hub import from_pretrained_fastai
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from blurr.text.modeling.all import *
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
learn = from_pretrained_fastai("arshy/medicalspecialty-deberta")
|
| 7 |
+
|
| 8 |
+
def predict(learn, inp:str):
|
| 9 |
+
preds = learn.blurr_predict([inp])[0]
|
| 10 |
+
preds_dict = dict(zip(preds['class_labels'], preds['probs']))
|
| 11 |
+
preds_dict = sorted(preds_dict.items(), key=operator.itemgetter(1), reverse=True)[:5]
|
| 12 |
+
preds_df = pd.DataFrame(preds_dict, columns=['Specialty', 'Probability'])
|
| 13 |
+
|
| 14 |
+
return preds_df
|
| 15 |
+
|
| 16 |
+
text = gr.inputs.Textbox()
|
| 17 |
+
output = gr.outputs.Dataframe()
|
| 18 |
+
|
| 19 |
+
intf = gr.Interface(fn=predict, inputs=text, outputs=output)
|
| 20 |
+
intf.launch()
|