prediksi-icd / app.py
javear's picture
Update app.py
ad0a18e
raw
history blame contribute delete
850 Bytes
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)