ashok2216 commited on
Commit
7194376
·
verified ·
1 Parent(s): 8b01b42

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -45
app.py CHANGED
@@ -6,54 +6,28 @@ from data_cleaning import preprocess
6
  from transformers import pipeline
7
  from data_integration import scrape_all_pages
8
 
9
- #@st.cache_data
10
- #def get_img_as_base64(file):
11
- # with open(file, "rb") as f:
12
- # data = f.read()
13
- # return base64.b64encode(data).decode()
14
-
15
-
16
- #img = get_img_as_base64("image.jpg")background-image: url("data:image/png;base64,{img}");
17
 
18
 
19
  page_bg_img = """
20
  <style>
21
- .stApp > header {
22
- background-color: transparent;
23
- }
24
-
25
  .stApp {
26
-
27
  background: rgb(80,255,235);
28
- background: linear-gradient(90deg, rgba(80,255,235,1) 0%, rgba(0,0,255,1) 50%, rgba(188,0,255,1) 92%);
 
29
  background-size: 150% 150%;
30
- animation: my_animation 10s ease infinite;
31
  }
32
-
33
  @keyframes my_animation {
34
- 0% {
35
- background-position: 0% 0%;
36
- }
37
- 25% {
38
- background-position: 0% 0%;
39
- }
40
- 50% {
41
- background-position: 100% 100%;
42
- }
43
- 75% {
44
- background-position: 100% 100%;
45
- }
46
- 100% {
47
- background-position: 0% 0%;
48
- }
49
  }
50
-
51
  </style>
52
  """
53
- # background-color:hsla(244,100%,50%,1);
54
- # background-image:
55
- # radial-gradient(at 40% 20%, hsla(266,100%,49%,1) 0px, transparent 50%),
56
- # radial-gradient(at 80% 0%, hsla(189,100%,56%,1) 0px, transparent 50%);
57
  st.markdown(page_bg_img, unsafe_allow_html=True)
58
  #st.image("logo.png", width=200, height=200)
59
 
@@ -63,23 +37,25 @@ st.markdown("")
63
  st.markdown("")
64
  st.markdown("")
65
  st.markdown("")
66
-
67
  st.subheader('Amazon Sentiment Analysis using FineTuned :red[GPT-2] Pre-Trained Model')
68
 
69
- sentiment_model = pipeline(model="ashok2216/gpt2-amazon-sentiment-classifier")
70
- # Example usage:-
71
- sample_url = 'https://www.amazon.in/Dell-Inspiron-i7-1255U-Processor-Platinum/product-reviews/B0C9F142V6/ref=cm_cr_dp_d_show_all_btm?ie=UTF8&reviewerType=all_reviews'
72
- url = st.text_input("Amazon product link", sample_url)
73
- st.button("Re-run")
74
- st.write("Done")
75
- st.subheader('', divider='rainbow')
 
 
 
 
76
 
77
  try:
78
  all_reviews = scrape_all_pages(url)
79
  # Convert to DataFrame for further analysis
80
  reviews = pd.DataFrame(all_reviews)
81
  reviews['processed_text'] = reviews['content'].apply(preprocess)
82
-
83
  # st.dataframe(reviews, use_container_width=True)
84
  # st.markdown(sentiment_model(['It is Super!']))
85
 
 
6
  from transformers import pipeline
7
  from data_integration import scrape_all_pages
8
 
 
 
 
 
 
 
 
 
9
 
10
 
11
  page_bg_img = """
12
  <style>
13
+ .stApp > header { background-color: transparent;}
 
 
 
14
  .stApp {
 
15
  background: rgb(80,255,235);
16
+ background: linear-gradient(90deg, rgba(80,255,235,1) 0%,
17
+ rgba(0,0,255,1) 50%, rgba(188,0,255,1) 92%);
18
  background-size: 150% 150%;
19
+ animation: my_animation 30s ease infinite;
20
  }
 
21
  @keyframes my_animation {
22
+ 0% {background-position: 0% 0%;}
23
+ 25% { background-position: 0% 0%;}
24
+ 50% {background-position: 100% 100%;}
25
+ 75% {background-position: 100% 100%;}
26
+ 100% {background-position: 0% 0%;}
 
 
 
 
 
 
 
 
 
 
27
  }
 
28
  </style>
29
  """
30
+
 
 
 
31
  st.markdown(page_bg_img, unsafe_allow_html=True)
32
  #st.image("logo.png", width=200, height=200)
33
 
 
37
  st.markdown("")
38
  st.markdown("")
39
  st.markdown("")
 
40
  st.subheader('Amazon Sentiment Analysis using FineTuned :red[GPT-2] Pre-Trained Model')
41
 
42
+ @st.cache_resource
43
+ def load_model():
44
+ sentiment_model = pipeline(model="ashok2216/gpt2-amazon-sentiment-classifier")
45
+ sample_url = 'https://www.amazon.in/Dell-Inspiron-i7-1255U-Processor-Platinum/product-reviews/B0C9F142V6/ref=cm_cr_dp_d_show_all_btm?ie=UTF8&reviewerType=all_reviews'
46
+ url = st.text_input("Amazon product link", sample_url)
47
+ st.button("Re-run")
48
+ st.write("Done")
49
+ st.subheader('', divider='rainbow')
50
+ return sentiment_model
51
+
52
+ model = load_model()
53
 
54
  try:
55
  all_reviews = scrape_all_pages(url)
56
  # Convert to DataFrame for further analysis
57
  reviews = pd.DataFrame(all_reviews)
58
  reviews['processed_text'] = reviews['content'].apply(preprocess)
 
59
  # st.dataframe(reviews, use_container_width=True)
60
  # st.markdown(sentiment_model(['It is Super!']))
61