Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,18 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
gr.Interface
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import torch
|
3 |
+
import gradio as gr
|
4 |
+
from transformers import AutoTokenizer, BertForSequenceClassification
|
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 |
+
demo = gr.Interface(fn=prompt,inputs= "text", outputs="text")
|
18 |
+
demo.launch(debug=True)
|