Spaces:
Runtime error
Runtime error
File size: 850 Bytes
cc425fb 0453d4c a4ca8d8 83a7ee5 37d7ae1 d6d5e5b 7ea4c80 6d1b056 a4ca8d8 6d1b056 ad0a18e 0715a41 4b33dc3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import streamlit as st
import logging
from transformers import AutoTokenizer, BertForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("AkshatSurolia/ICD-10-Code-Prediction")
model = BertForSequenceClassification.from_pretrained("AkshatSurolia/ICD-10-Code-Prediction")
config = model.config
from googletrans import Translator
translator = Translator()
text = st.text_area('enter some text!')
#text = "subarachnoid hemorrhage scalp laceration service: surgery major surgical or invasive"
#pipe = pipeline('sentiment-analysis')
if text:
translated = translator.translate(text)
encoded_input = tokenizer(translated.text, return_tensors='pt')
output = model(**encoded_input)
results = output.logits.detach().cpu().numpy()[0].argsort()[::-1][:5]
rout = [ config.id2label[ids] for ids in results]
st.write(rout) |