Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,16 @@ from transformers import AutoTokenizer, BertForSequenceClassification
|
|
3 |
|
4 |
import gradio as gr
|
5 |
|
6 |
-
|
7 |
-
|
|
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
import gradio as gr
|
5 |
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained("AkshatSurolia/ICD-10-Code-Prediction")
|
7 |
+
model = BertForSequenceClassification.from_pretrained("AkshatSurolia/ICD-10-Code-Prediction")
|
8 |
+
config = model.config
|
9 |
|
10 |
+
def prompt(text):
|
11 |
+
encoded_input = tokenizer(text, return_tensors='pt')
|
12 |
+
output = model(**encoded_input)
|
13 |
+
results = output.logits.detach().cpu().numpy()[0].argsort()[::-1][:5]
|
14 |
+
return [ config.id2label[ids] for ids in results]
|
15 |
+
#return tokenizer.decode(output[0][0].argmax(dim=-1))
|
16 |
+
|
17 |
+
gr.Interface.load(fn=prompt, inputs="text", outputs="text",
|
18 |
+
title="ICD 10 Code Prediction", description="type in a disease and it will predict its ICD-10 codes",).launch(debug=True)
|