sumonta056 commited on
Commit
0ebdcd8
Β·
1 Parent(s): 1c283bc

update: structure of folder

Browse files
app.py CHANGED
@@ -2,7 +2,7 @@ import streamlit as st
2
  from transformers import BertForSequenceClassification, BertTokenizerFast, pipeline
3
 
4
  # Load the BERT model and tokenizer
5
- model_path = "./"
6
  model = BertForSequenceClassification.from_pretrained(model_path)
7
  tokenizer = BertTokenizerFast.from_pretrained(model_path)
8
  nlp = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
@@ -30,30 +30,73 @@ def get_emoji(label):
30
  else:
31
  return "πŸ™‚"
32
 
33
- # Streamlit app
34
- st.set_page_config(page_title="G-Bert: Emotion Analysis", page_icon="😊", layout="centered")
 
 
 
 
35
 
36
- # Title
37
- st.title("G-Bert: Emotion Analysis")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  # Text input
40
- st.write("Enter some text below, and G-Bert will analyze its emotion!")
41
- text = st.text_area("Input Text", height=200)
42
 
43
  # Analyze button
44
- if st.button("Analyze Emotion"):
45
  if text.strip():
46
  label, score = analyze_sentiment(text)
47
  if label and score:
48
  emoji = get_emoji(label)
49
- st.subheader(f"Emotion: {label}")
50
- st.markdown(f"**Confidence Score:** {score:.2f}")
51
- st.markdown(f"{emoji} **{label}**")
 
52
  else:
53
- st.error("Something went wrong with the analysis.")
54
  else:
55
- st.warning("Please enter some text to analyze.")
56
 
57
- # Footer
58
  st.markdown("---")
59
- st.markdown("Built with ❀️ using Hugging Face and Streamlit")
 
 
 
 
 
 
 
 
2
  from transformers import BertForSequenceClassification, BertTokenizerFast, pipeline
3
 
4
  # Load the BERT model and tokenizer
5
+ model_path = "./model/"
6
  model = BertForSequenceClassification.from_pretrained(model_path)
7
  tokenizer = BertTokenizerFast.from_pretrained(model_path)
8
  nlp = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
 
30
  else:
31
  return "πŸ™‚"
32
 
33
+ # Streamlit app configuration
34
+ st.set_page_config(
35
+ page_title="G-Bert: Emotion Analysis",
36
+ page_icon="😊",
37
+ layout="centered"
38
+ )
39
 
40
+ # Custom CSS for a modern UI
41
+ st.markdown("""
42
+ <style>
43
+ body {
44
+ background: linear-gradient(to right, #6a11cb, #2575fc);
45
+ color: white;
46
+ font-family: 'Segoe UI', sans-serif;
47
+ }
48
+ .stButton button {
49
+ background-color: #2575fc;
50
+ color: white;
51
+ border-radius: 8px;
52
+ font-size: 16px;
53
+ font-weight: bold;
54
+ }
55
+ .stTextArea textarea {
56
+ background: #f5f5f5;
57
+ border-radius: 8px;
58
+ }
59
+ footer {
60
+ font-size: 14px;
61
+ text-align: center;
62
+ }
63
+ footer a {
64
+ color: #2575fc;
65
+ text-decoration: none;
66
+ }
67
+ </style>
68
+ """, unsafe_allow_html=True)
69
+
70
+ # Title and description
71
+ st.title("🌟 G-Bert: Emotion Analysis")
72
+ st.write("Analyze the emotion behind your text with **G-Bert**, powered by Hugging Face transformers.")
73
 
74
  # Text input
75
+ st.write("Enter some text below, and G-Bert will analyze its emotion for you!")
76
+ text = st.text_area("Input Text", height=150, placeholder="Type your text here...")
77
 
78
  # Analyze button
79
+ if st.button("✨ Analyze Emotion ✨"):
80
  if text.strip():
81
  label, score = analyze_sentiment(text)
82
  if label and score:
83
  emoji = get_emoji(label)
84
+ st.markdown(f"""
85
+ <h2 style="text-align:center;">{emoji} Emotion: {label} {emoji}</h2>
86
+ <p style="text-align:center; font-size:20px;">Confidence Score: <strong>{score:.2f}</strong></p>
87
+ """, unsafe_allow_html=True)
88
  else:
89
+ st.error("🚨 Something went wrong with the analysis.")
90
  else:
91
+ st.warning("⚠️ Please enter some text to analyze.")
92
 
93
+ # Footer with authorship
94
  st.markdown("---")
95
+ st.markdown("""
96
+ <footer>
97
+ Built with ❀️ by
98
+ <a href="https://github.com/sumonta-saha" target="_blank">Sumonta Saha</a>,
99
+ <a href="https://github.com/mridul-pk" target="_blank">Mridul</a>, and
100
+ <a href="https://github.com/promi-mojumder" target="_blank">Promi Mojumder</a>.
101
+ </footer>
102
+ """, unsafe_allow_html=True)
README.md β†’ model/README.md RENAMED
File without changes
config.json β†’ model/config.json RENAMED
File without changes
model.safetensors β†’ model/model.safetensors RENAMED
File without changes
requirements.txt β†’ model/requirements.txt RENAMED
File without changes
special_tokens_map.json β†’ model/special_tokens_map.json RENAMED
File without changes
tokenizer.json β†’ model/tokenizer.json RENAMED
File without changes
tokenizer_config.json β†’ model/tokenizer_config.json RENAMED
File without changes
training_args.bin β†’ model/training_args.bin RENAMED
File without changes
vocab.txt β†’ model/vocab.txt RENAMED
File without changes