Mpavan45 commited on
Commit
2352d40
·
verified ·
1 Parent(s): 0a14fb8

Update app.py

Browse files

![Gorgeous Travel Landscape Photography by Kai Grossmann.jpeg](https://cdn-uploads.huggingface.co/production/uploads/675fab3a2d0851e23d23cad3/NUr5kRtYi71HClXecxPTf.jpeg)

Files changed (1) hide show
  1. app.py +33 -107
app.py CHANGED
@@ -1,116 +1,42 @@
1
- # import streamlit as st
2
- # from transformers import pipeline
3
- # import re
4
-
5
- # # Load the model
6
- # classifier = pipeline("text-classification", model="Mpavan45/Telugu_Sentimental_Analysis")
7
-
8
- # # CSS styling
9
- # st.markdown("""
10
- # <style>
11
- # .radium-title {
12
- # font-size: 40px;
13
- # text-align: center;
14
- # color: #fff;
15
- # padding: 10px;
16
- # border-radius: 10px;
17
- # background: linear-gradient(90deg, #ff416c, #ff4b2b);
18
- # box-shadow: 0 0 20px #ff416c, 0 0 30px #ff4b2b;
19
- # }
20
- # .radium-label {
21
- # font-size: 24px;
22
- # font-weight: bold;
23
- # color: white;
24
- # padding: 10px;
25
- # border-radius: 8px;
26
- # background: linear-gradient(90deg, #36d1dc, #5b86e5);
27
- # display: inline-block;
28
- # margin-top: 10px;
29
- # }
30
- # </style>
31
- # """, unsafe_allow_html=True)
32
-
33
- # st.markdown('<div class="radium-title">Sentiment Analysis with BERT</div>', unsafe_allow_html=True)
34
- # st.write("This app uses a fine-tuned BERT model to classify **Telugu text** as Positive, Negative, or Neutral. English is not supported.")
35
-
36
- # # Emoji mapping
37
- # label_map = {
38
- # "LABEL_0": ("Negative", "😞"),
39
- # "LABEL_1": ("Neutral", "😐"),
40
- # "LABEL_2": ("Positive", "😊")
41
- # }
42
-
43
- # # Telugu validation (at least 70% of letters must be Telugu)
44
- # def is_telugu_text(text):
45
- # telugu_chars = re.findall(r'[\u0C00-\u0C7F]', text)
46
- # total_chars = re.findall(r'\S', text) # non-space chars
47
- # if not total_chars:
48
- # return False
49
- # return len(telugu_chars) / len(total_chars) >= 0.7
50
-
51
- # # Session state init
52
- # if "text_input" not in st.session_state:
53
- # st.session_state.text_input = ""
54
- # if "result_shown" not in st.session_state:
55
- # st.session_state.result_shown = False
56
- # if "from_example" not in st.session_state:
57
- # st.session_state.from_example = False
58
-
59
- # # Examples
60
- # st.subheader("Try one of the following examples:")
61
- # examples = [
62
- # "ఈ ఆహారం చాలా చెడుగా ఉంది",
63
- # "నాకు ఈ రోజు చాలా సంతోషంగా ఉంది",
64
- # "నేను ఈ వార్తలకు చాలా బాధపడ్డాను",
65
- # "ఈ చిత్రం నాకు చాలా భయంకరంగా ఉంది",
66
- # "ఈ సెల్ఫీ చాలా అందంగా ఉంది",
67
- # "ఈ వాతావరణం నాకు చాలా ఉష్ణంగా ఉంది"
68
- # ]
69
-
70
- # for i in range(0, len(examples), 2):
71
- # cols = st.columns(2)
72
- # for j in range(2):
73
- # if i + j < len(examples):
74
- # example = examples[i + j]
75
- # if cols[j].button(example[:30] + "..."):
76
- # st.session_state.text_input = example
77
- # st.session_state.result_shown = True
78
- # st.session_state.from_example = True
79
-
80
- # # Text area
81
- # text_input = st.text_area("Enter text to analyze sentiment (Telugu only):", value=st.session_state.text_input, height=150)
82
-
83
- # # Reset if input changed
84
- # if st.session_state.from_example and text_input != st.session_state.text_input:
85
- # st.session_state.from_example = False
86
- # st.session_state.result_shown = False
87
-
88
- # # Analyze button
89
- # if st.button("Analyze Sentiment"):
90
- # st.session_state.text_input = text_input
91
- # st.session_state.result_shown = True
92
- # st.session_state.from_example = False
93
-
94
- # # Predict only if valid Telugu
95
- # if st.session_state.result_shown:
96
- # input_text = st.session_state.text_input.strip()
97
- # if not input_text:
98
- # st.warning("Please enter some text to analyze!")
99
- # st.session_state.result_shown = False
100
- # elif not is_telugu_text(input_text):
101
- # st.error("Please enter valid **Telugu** text. English or other languages are not supported.")
102
- # st.session_state.result_shown = False
103
- # else:
104
- # result = classifier(input_text)
105
- # raw_label = result[0]['label']
106
- # sentiment, emoji = label_map.get(raw_label, (raw_label, ""))
107
- # st.markdown(f'<div class="radium-label">Sentiment: {sentiment} {emoji}</div>', unsafe_allow_html=True)
108
  import streamlit as st
109
  import re
110
  from transformers import pipeline
111
 
112
  # Load the model
113
  classifier = pipeline("text-classification", model="Mpavan45/Telugu_Sentimental_Analysis")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
 
115
  # CSS for radium effect
116
  st.markdown("""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  import re
3
  from transformers import pipeline
4
 
5
  # Load the model
6
  classifier = pipeline("text-classification", model="Mpavan45/Telugu_Sentimental_Analysis")
7
+ st.markdown("""
8
+ <style>
9
+ /* Background image for the entire app */
10
+ .stApp {
11
+ background-image: url('https://cdn-uploads.huggingface.co/production/uploads/675fab3a2d0851e23d23cad3/NUr5kRtYi71HClXecxPTf.jpeg'); /* Replace with your image URL */
12
+ background-size: cover;
13
+ background-position: center;
14
+ background-repeat: no-repeat;
15
+ background-attachment: fixed;
16
+ }
17
+ /* Radium title styling */
18
+ .radium-title {
19
+ font-size: 40px;
20
+ text-align: center;
21
+ color: #fff;
22
+ padding: 10px;
23
+ border-radius: 10px;
24
+ background: linear-gradient(90deg, #ff416c, #ff4b2b);
25
+ box-shadow: 0 0 20px #ff416c, 0 0 30px #ff4b2b;
26
+ }
27
+ /* Radium label styling */
28
+ .radium-label {
29
+ font-size: 24px;
30
+ font-weight: bold;
31
+ color: white;
32
+ padding: 10px;
33
+ border-radius: 8px;
34
+ background: linear-gradient(90deg, #36d1dc, #5b86e5);
35
+ display: inline-block;
36
+ margin-top: 10px;
37
+ }
38
+ </style>
39
+ """, unsafe_allow_html=True)
40
 
41
  # CSS for radium effect
42
  st.markdown("""