byinab commited on
Commit
92fa91b
Β·
verified Β·
1 Parent(s): 39fd164

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +18 -9
src/streamlit_app.py CHANGED
@@ -1,6 +1,6 @@
1
  import streamlit as st
2
  import torch
3
- from transformers import pipeline
4
  import time
5
 
6
  st.set_page_config(
@@ -21,18 +21,27 @@ st.markdown("""
21
 
22
  @st.cache_resource
23
  def load_pipelines():
 
24
  with st.spinner('πŸ”„ Loading AI models (2-3 min)...'):
25
- classifier = pipeline("text-classification", model="distilbert-base-uncased")
 
 
 
 
 
 
 
26
  generator = pipeline("text-generation", model="Kunal7370944861/Email-Writer-AI")
27
  translator = pipeline("translation", model="DDDSSS/translation_en-zh")
 
28
  return classifier, generator, translator
29
 
30
  # Load models safely
31
  try:
32
  classifier, generator, translator = load_pipelines()
33
- st.success("βœ… All 3 pipelines ready!")
34
  except Exception as e:
35
- st.error(f"Model loading error: {str(e)}")
36
  st.stop()
37
 
38
  def classify_email(text, classifier):
@@ -65,10 +74,10 @@ def translate_reply(text, translator):
65
  st.markdown('<h1 class="main-header">πŸ€– Email Reply Assistant</h1>', unsafe_allow_html=True)
66
  st.markdown("**AI-powered: Classify β†’ Generate Reply β†’ Translate to Chinese**")
67
 
68
- # Sidebar
69
  with st.sidebar:
70
  st.header("πŸ”§ Pipeline Status")
71
- st.success("βœ… **Pipeline 1**: `distilbert-base-uncased`")
72
  st.success("βœ… **Pipeline 2**: `Kunal7370944861/Email-Writer-AI`")
73
  st.success("βœ… **Pipeline 3**: `DDDSSS/translation_en-zh`")
74
  st.markdown("---")
@@ -98,10 +107,10 @@ with col2:
98
  if 'processed' in st.session_state and st.session_state.processed:
99
  email_text = st.session_state.email
100
 
101
- # Pipeline 1: Classification
102
  with st.container():
103
  st.markdown('<div class="pipeline-card">', unsafe_allow_html=True)
104
- st.markdown("### πŸ”’ **Pipeline 1: Email Classification**")
105
  label, score = classify_email(email_text, classifier)
106
 
107
  col_a, col_b = st.columns(2)
@@ -150,4 +159,4 @@ with col2:
150
  st.markdown('</div>', unsafe_allow_html=True)
151
 
152
  st.markdown("---")
153
- st.markdown("*Powered by Streamlit + Transformers | Deployed on Hugging Face Spaces*")
 
1
  import streamlit as st
2
  import torch
3
+ from transformers import pipeline, AutoTokenizer
4
  import time
5
 
6
  st.set_page_config(
 
21
 
22
  @st.cache_resource
23
  def load_pipelines():
24
+ """Load all 3 pipelines with custom classifier"""
25
  with st.spinner('πŸ”„ Loading AI models (2-3 min)...'):
26
+ # βœ… YOUR CUSTOM CLASSIFIER (replaced)
27
+ tok = AutoTokenizer.from_pretrained("distilbert-base-uncased")
28
+ classifier = pipeline(
29
+ "text-classification",
30
+ model="byinab/custom-email-classifier",
31
+ tokenizer=tok,
32
+ )
33
+
34
  generator = pipeline("text-generation", model="Kunal7370944861/Email-Writer-AI")
35
  translator = pipeline("translation", model="DDDSSS/translation_en-zh")
36
+
37
  return classifier, generator, translator
38
 
39
  # Load models safely
40
  try:
41
  classifier, generator, translator = load_pipelines()
42
+ st.success("βœ… All 3 pipelines ready! (Custom Email Classifier Loaded)")
43
  except Exception as e:
44
+ st.error(f"❌ Model loading error: {str(e)}")
45
  st.stop()
46
 
47
  def classify_email(text, classifier):
 
74
  st.markdown('<h1 class="main-header">πŸ€– Email Reply Assistant</h1>', unsafe_allow_html=True)
75
  st.markdown("**AI-powered: Classify β†’ Generate Reply β†’ Translate to Chinese**")
76
 
77
+ # Sidebar - UPDATED with your custom classifier
78
  with st.sidebar:
79
  st.header("πŸ”§ Pipeline Status")
80
+ st.success("βœ… **Pipeline 1**: `byinab/custom-email-classifier`")
81
  st.success("βœ… **Pipeline 2**: `Kunal7370944861/Email-Writer-AI`")
82
  st.success("βœ… **Pipeline 3**: `DDDSSS/translation_en-zh`")
83
  st.markdown("---")
 
107
  if 'processed' in st.session_state and st.session_state.processed:
108
  email_text = st.session_state.email
109
 
110
+ # Pipeline 1: YOUR CUSTOM CLASSIFIER
111
  with st.container():
112
  st.markdown('<div class="pipeline-card">', unsafe_allow_html=True)
113
+ st.markdown("### πŸ”’ **Pipeline 1: Custom Email Classifier**")
114
  label, score = classify_email(email_text, classifier)
115
 
116
  col_a, col_b = st.columns(2)
 
159
  st.markdown('</div>', unsafe_allow_html=True)
160
 
161
  st.markdown("---")
162
+ st.markdown("*Powered by Streamlit + Transformers | Custom Email Classifier*")