Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
| 3 |
+
|
| 4 |
+
# Load the HealthScribe Clinical Note Generator model and tokenizer
|
| 5 |
+
@st.cache_resource
|
| 6 |
+
def load_model():
|
| 7 |
+
model_name = "har1/HealthScribe-Clinical_Note_Generator"
|
| 8 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 9 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
| 10 |
+
return model, tokenizer
|
| 11 |
+
|
| 12 |
+
model, tokenizer = load_model()
|
| 13 |
+
|
| 14 |
+
st.title("HealthScribe Clinical Note Generator")
|
| 15 |
+
st.write("Generate clinical notes based on input text.")
|
| 16 |
+
|
| 17 |
+
# Input section
|
| 18 |
+
input_text = st.text_area("Enter patient information or medical notes:", height=200)
|
| 19 |
+
|
| 20 |
+
if st.button("Generate Clinical Note"):
|
| 21 |
+
if input_text.strip():
|
| 22 |
+
# Tokenize and generate
|
| 23 |
+
inputs = tokenizer(input_text, return_tensors="pt", max_length=512, truncation=True)
|
| 24 |
+
outputs = model.generate(inputs["input_ids"], max_length=512, num_beams=5, early_stopping=True)
|
| 25 |
+
generated_note = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 26 |
+
|
| 27 |
+
# Display the result
|
| 28 |
+
st.subheader("Generated Clinical Note")
|
| 29 |
+
st.write(generated_note)
|
| 30 |
+
else:
|
| 31 |
+
st.warning("Please enter some text to generate a clinical note.")
|