shubhammukherjee commited on
Commit
e9f2b62
·
verified ·
1 Parent(s): 6557c8b
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -1,19 +1,22 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- # Assume you have fine-tuned models and their names are listed here
5
  available_models = [
6
  "facebook/t5-small",
 
 
7
  "google/pegasus-xsum",
 
8
  "sshleifer/distilbart-cnn-12-6",
9
- "your_fine_tuned_news_model", # Replace with your fine-tuned model name
10
- "your_fine_tuned_long_doc_model", # Replace with another fine-tuned model name
11
- # Add more of your fine-tuned models here
 
12
  ]
13
 
14
  @st.cache_resource
15
  def load_summarizer(model_name):
16
- """Loads the summarization pipeline for a given model."""
17
  try:
18
  summarizer = pipeline("summarization", model=model_name)
19
  return summarizer
@@ -21,13 +24,13 @@ def load_summarizer(model_name):
21
  st.error(f"Error loading model {model_name}: {e}")
22
  return None
23
 
24
- st.title("Advanced Text Summarization App")
25
 
26
  text_to_summarize = st.text_area("Enter text to summarize:", height=300)
27
 
28
- selected_model = st.selectbox("Choose a summarization model:", available_models)
29
 
30
- # Parameters for controlling summarization
31
  max_length = st.sidebar.slider("Max Summary Length:", min_value=50, max_value=500, value=150)
32
  min_length = st.sidebar.slider("Min Summary Length:", min_value=10, max_value=250, value=30)
33
  temperature = st.sidebar.slider("Temperature (for sampling):", min_value=0.0, max_value=1.0, value=0.0, step=0.01, help="Higher values make the output more random.")
@@ -63,7 +66,8 @@ if st.button("Summarize"):
63
  st.sidebar.header("About")
64
  st.sidebar.info(
65
  "This app uses the `transformers` library from Hugging Face "
66
- "to perform text summarization. You can select from various "
67
- "pre-trained and potentially fine-tuned models. Experiment with "
68
- "the parameters in the sidebar to control the summarization process."
 
69
  )
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
 
4
  available_models = [
5
  "facebook/t5-small",
6
+ "facebook/t5-base",
7
+ "facebook/t5-large",
8
  "google/pegasus-xsum",
9
+ "google/pegasus-cnn_dailymail",
10
  "sshleifer/distilbart-cnn-12-6",
11
+ "allenai/led-base-16384",
12
+ "google/mt5-small",
13
+ "google/mt5-base",
14
+ # Add more models as needed
15
  ]
16
 
17
  @st.cache_resource
18
  def load_summarizer(model_name):
19
+ """Loads the summarization pipeline for a given model from Hugging Face."""
20
  try:
21
  summarizer = pipeline("summarization", model=model_name)
22
  return summarizer
 
24
  st.error(f"Error loading model {model_name}: {e}")
25
  return None
26
 
27
+ st.title("Hugging Face Text Summarization App")
28
 
29
  text_to_summarize = st.text_area("Enter text to summarize:", height=300)
30
 
31
+ selected_model = st.selectbox("Choose a summarization model from Hugging Face:", available_models)
32
 
33
+ st.sidebar.header("Summarization Parameters")
34
  max_length = st.sidebar.slider("Max Summary Length:", min_value=50, max_value=500, value=150)
35
  min_length = st.sidebar.slider("Min Summary Length:", min_value=10, max_value=250, value=30)
36
  temperature = st.sidebar.slider("Temperature (for sampling):", min_value=0.0, max_value=1.0, value=0.0, step=0.01, help="Higher values make the output more random.")
 
66
  st.sidebar.header("About")
67
  st.sidebar.info(
68
  "This app uses the `transformers` library from Hugging Face "
69
+ "to perform text summarization. You can select from a variety of "
70
+ "pre-trained models available on the Hugging Face Model Hub. "
71
+ "Experiment with the parameters in the sidebar to control the "
72
+ "summarization process."
73
  )