mdasad3617 commited on
Commit
0927160
·
verified ·
1 Parent(s): 85b4877

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -8,7 +8,9 @@ def setup_logging():
8
  logging.basicConfig(
9
  level=logging.INFO,
10
  format='%(asctime)s - %(levelname)s - %(message)s',
11
- handlers=[logging.StreamHandler()]
 
 
12
  )
13
 
14
  # Function to extract text from a PDF file
@@ -23,8 +25,8 @@ def main():
23
  setup_logging()
24
  logging.info("Starting the Streamlit app.")
25
 
26
- # Initialize the medical text summarization pipeline
27
- summarizer = pipeline("summarization", model="your/medical_text_summarization_model")
28
 
29
  # Streamlit UI
30
  st.title("GenAI Lab Report Analyzer")
@@ -51,7 +53,7 @@ def main():
51
  elif input_type == "Audio":
52
  audio = st.file_uploader("Upload your audio file:", type=["wav", "mp3", "m4a"])
53
 
54
- if st.button("Analyze Report"):
55
  try:
56
  summary = None
57
  if input_type == "Text" and text:
@@ -74,6 +76,7 @@ def main():
74
  summary = "Invalid input. Please provide a valid file or text."
75
  logging.warning("Invalid input type provided.")
76
 
 
77
  st.text_area("Report Result:", summary[0]['summary_text'] if isinstance(summary, list) else summary, height=200)
78
  except Exception as e:
79
  logging.error(f"Error during summarization: {e}")
 
8
  logging.basicConfig(
9
  level=logging.INFO,
10
  format='%(asctime)s - %(levelname)s - %(message)s',
11
+ handlers=[
12
+ logging.StreamHandler()
13
+ ]
14
  )
15
 
16
  # Function to extract text from a PDF file
 
25
  setup_logging()
26
  logging.info("Starting the Streamlit app.")
27
 
28
+ # Initialize the summarization pipeline with a public model for long medical texts
29
+ summarizer = pipeline("summarization", model="allenai/led-large-16384-arxiv")
30
 
31
  # Streamlit UI
32
  st.title("GenAI Lab Report Analyzer")
 
53
  elif input_type == "Audio":
54
  audio = st.file_uploader("Upload your audio file:", type=["wav", "mp3", "m4a"])
55
 
56
+ if st.button("Report Result"):
57
  try:
58
  summary = None
59
  if input_type == "Text" and text:
 
76
  summary = "Invalid input. Please provide a valid file or text."
77
  logging.warning("Invalid input type provided.")
78
 
79
+ # Display the summarized result
80
  st.text_area("Report Result:", summary[0]['summary_text'] if isinstance(summary, list) else summary, height=200)
81
  except Exception as e:
82
  logging.error(f"Error during summarization: {e}")