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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -8,9 +8,7 @@ def setup_logging():
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,8 +23,8 @@ def main():
25
  setup_logging()
26
  logging.info("Starting the Streamlit app.")
27
 
28
- # Initialize the summarization pipeline
29
- summarizer = pipeline("summarization")
30
 
31
  # Streamlit UI
32
  st.title("GenAI Lab Report Analyzer")
@@ -53,21 +51,21 @@ def main():
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:
60
  logging.info("Processing text input.")
61
- summary = summarizer(text, max_length=130, min_length=30, do_sample=False)
62
  logging.info("Text input processed successfully.")
63
  elif input_type == "Text File" and file:
64
  logging.info(f"Processing text file: {file.name}")
65
  text = file.read().decode("utf-8") # Assuming UTF-8 encoding
66
- summary = summarizer(text, max_length=130, min_length=30, do_sample=False)
67
  elif input_type == "PDF" and file:
68
  logging.info(f"Processing PDF file: {file.name}")
69
  text = extract_text_from_pdf(file)
70
- summary = summarizer(text, max_length=130, min_length=30, do_sample=False)
71
  elif input_type == "Audio" and audio:
72
  logging.info("Processing audio input.")
73
  # Add audio processing logic here
 
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
  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
  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:
58
  logging.info("Processing text input.")
59
+ summary = summarizer(text, max_length=2000, min_length=1500, do_sample=False)
60
  logging.info("Text input processed successfully.")
61
  elif input_type == "Text File" and file:
62
  logging.info(f"Processing text file: {file.name}")
63
  text = file.read().decode("utf-8") # Assuming UTF-8 encoding
64
+ summary = summarizer(text, max_length=2000, min_length=1500, do_sample=False)
65
  elif input_type == "PDF" and file:
66
  logging.info(f"Processing PDF file: {file.name}")
67
  text = extract_text_from_pdf(file)
68
+ summary = summarizer(text, max_length=2000, min_length=1500, do_sample=False)
69
  elif input_type == "Audio" and audio:
70
  logging.info("Processing audio input.")
71
  # Add audio processing logic here