rajuesaa commited on
Commit
c4805ce
·
1 Parent(s): 3ce878b

Fix UI font visibility and summarization task error

Browse files
Files changed (3) hide show
  1. app.py +15 -2
  2. requirements.txt +4 -1
  3. utils.py +18 -2
app.py CHANGED
@@ -23,8 +23,16 @@ if 'extracted_content' not in st.session_state:
23
  # Custom CSS for Premium Look
24
  st.markdown("""
25
  <style>
 
 
 
 
26
  .main {
27
  background-color: #0e1117;
 
 
 
 
28
  }
29
  .stTabs [data-baseweb="tab-list"] {
30
  gap: 24px;
@@ -35,7 +43,7 @@ st.markdown("""
35
  white-space: pre-wrap;
36
  background-color: #1a1c24;
37
  border-radius: 4px 4px 0px 0px;
38
- color: #ffffff;
39
  font-size: 16px;
40
  font-weight: 500;
41
  padding: 10px 20px;
@@ -51,6 +59,7 @@ st.markdown("""
51
  border-radius: 12px;
52
  padding: 20px;
53
  margin-bottom: 20px;
 
54
  }
55
  .platform-card {
56
  background: #1a1c24;
@@ -58,15 +67,19 @@ st.markdown("""
58
  padding: 15px;
59
  border-radius: 8px;
60
  margin-bottom: 10px;
 
61
  }
62
  .sidebar-pro-cta {
63
  background: linear-gradient(135deg, #6d28d9, #9333ea);
64
- color: white;
65
  padding: 15px;
66
  border-radius: 8px;
67
  text-align: center;
68
  margin-top: 20px;
69
  }
 
 
 
70
  </style>
71
  """, unsafe_allow_html=True)
72
 
 
23
  # Custom CSS for Premium Look
24
  st.markdown("""
25
  <style>
26
+ /* Global Text Color */
27
+ .stApp {
28
+ color: #ffffff;
29
+ }
30
  .main {
31
  background-color: #0e1117;
32
+ color: #ffffff;
33
+ }
34
+ p, span, label, h1, h2, h3, h4, h5, h6 {
35
+ color: #ffffff !important;
36
  }
37
  .stTabs [data-baseweb="tab-list"] {
38
  gap: 24px;
 
43
  white-space: pre-wrap;
44
  background-color: #1a1c24;
45
  border-radius: 4px 4px 0px 0px;
46
+ color: #ffffff !important;
47
  font-size: 16px;
48
  font-weight: 500;
49
  padding: 10px 20px;
 
59
  border-radius: 12px;
60
  padding: 20px;
61
  margin-bottom: 20px;
62
+ color: #ffffff;
63
  }
64
  .platform-card {
65
  background: #1a1c24;
 
67
  padding: 15px;
68
  border-radius: 8px;
69
  margin-bottom: 10px;
70
+ color: #ffffff;
71
  }
72
  .sidebar-pro-cta {
73
  background: linear-gradient(135deg, #6d28d9, #9333ea);
74
+ color: white !important;
75
  padding: 15px;
76
  border-radius: 8px;
77
  text-align: center;
78
  margin-top: 20px;
79
  }
80
+ .sidebar-pro-cta small, .sidebar-pro-cta strong {
81
+ color: white !important;
82
+ }
83
  </style>
84
  """, unsafe_allow_html=True)
85
 
requirements.txt CHANGED
@@ -1,6 +1,9 @@
1
  streamlit
2
- transformers
3
  torch
 
 
 
4
  feedparser
5
  beautifulsoup4
6
  requests
 
1
  streamlit
2
+ transformers[torch]
3
  torch
4
+ sentencepiece
5
+ protobuf
6
+ pyyaml
7
  feedparser
8
  beautifulsoup4
9
  requests
utils.py CHANGED
@@ -65,7 +65,17 @@ class ForgeAI:
65
  @staticmethod
66
  @st.cache_resource
67
  def get_summarizer():
68
- return pipeline("summarization", model="facebook/bart-large-cnn")
 
 
 
 
 
 
 
 
 
 
69
 
70
  @staticmethod
71
  @st.cache_resource
@@ -83,7 +93,13 @@ class ForgeAI:
83
  # Generate summary (limited length for social)
84
  chunk_size = 1000
85
  input_text = content[:chunk_size]
86
- summary = summarizer(input_text, max_length=150, min_length=50, do_sample=False)[0]['summary_text']
 
 
 
 
 
 
87
 
88
  results = {}
89
  for platform in platforms:
 
65
  @staticmethod
66
  @st.cache_resource
67
  def get_summarizer():
68
+ try:
69
+ return pipeline("summarization", model="facebook/bart-large-cnn")
70
+ except KeyError:
71
+ # Fallback for environments where 'summarization' task isn't registered
72
+ # But 'text-generation' is. Note: BART might not work perfectly with 'text-generation'
73
+ # in all versions, so we try a different approach or model if needed.
74
+ try:
75
+ return pipeline("text-generation", model="facebook/bart-large-cnn")
76
+ except:
77
+ # Ultimate fallback to a small text-generation model if BART fails
78
+ return pipeline("text-generation", model="gpt2")
79
 
80
  @staticmethod
81
  @st.cache_resource
 
93
  # Generate summary (limited length for social)
94
  chunk_size = 1000
95
  input_text = content[:chunk_size]
96
+ summary_obj = summarizer(input_text, max_length=150, min_length=50, do_sample=False)[0]
97
+
98
+ # Handle difference between summarization and text-generation output
99
+ if 'summary_text' in summary_obj:
100
+ summary = summary_obj['summary_text']
101
+ else:
102
+ summary = summary_obj.get('generated_text', str(summary_obj))
103
 
104
  results = {}
105
  for platform in platforms: