clb5114 commited on
Commit
d474ee1
·
verified ·
1 Parent(s): 8c0a0f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -1,4 +1,3 @@
1
- # app.py
2
  import streamlit as st
3
  from transformers import pipeline
4
  import time
@@ -36,7 +35,6 @@ def load_css():
36
 
37
  @st.cache_resource(show_spinner=False)
38
  def load_models():
39
- # 移除所有Streamlit UI组件
40
  summarizer = pipeline(
41
  "text-generation",
42
  model="Lin0He/text-summary-gpt2-short",
@@ -92,7 +90,6 @@ def main():
92
  return
93
 
94
  with st.spinner('🔍 AI is analyzing...'):
95
- # 将模型加载与UI反馈分离
96
  with st.spinner('🚀 Loading AI models...'):
97
  summarizer, classifier = load_models()
98
 
@@ -122,4 +119,17 @@ def main():
122
  with col2:
123
  progress_color = "#4CAF50" if label=="Positive 👍" else "#FF5252"
124
  st.markdown(f"""
125
- <div style="
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
  import time
 
35
 
36
  @st.cache_resource(show_spinner=False)
37
  def load_models():
 
38
  summarizer = pipeline(
39
  "text-generation",
40
  model="Lin0He/text-summary-gpt2-short",
 
90
  return
91
 
92
  with st.spinner('🔍 AI is analyzing...'):
 
93
  with st.spinner('🚀 Loading AI models...'):
94
  summarizer, classifier = load_models()
95
 
 
119
  with col2:
120
  progress_color = "#4CAF50" if label=="Positive 👍" else "#FF5252"
121
  st.markdown(f"""
122
+ <div style="
123
+ background: {progress_color}10;
124
+ border-radius: 10px;
125
+ padding: 15px;
126
+ ">
127
+ <div style="font-size: 14px; color: {progress_color}; margin-bottom: 8px;">Sentiment Intensity</div>
128
+ <div style="height: 8px; background: #eee; border-radius: 4px;">
129
+ <div style="width: {positive_score*100}%; height: 100%; background: {progress_color}; border-radius: 4px;"></div>
130
+ </div>
131
+ </div>
132
+ """, unsafe_allow_html=True)
133
+
134
+ if __name__ == "__main__":
135
+ main()