KishanKumar001
commited on
Commit
·
7c09551
1
Parent(s):
5f8a61a
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
-
import matplotlib
|
3 |
-
matplotlib.use('Agg') # Use the 'Agg' backend for non-interactive use
|
4 |
import streamlit as st
|
5 |
-
import tkinter as tk
|
6 |
-
from tkinter import scrolledtext
|
7 |
import requests
|
8 |
|
9 |
SECRET_TOKEN = os.getenv("SECRET_TOKEN")
|
@@ -17,7 +37,12 @@ def query(payload):
|
|
17 |
|
18 |
user_query = st.text_area("Enter your text:")
|
19 |
if st.button("Analyze Sentiment"):
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
21 |
st.text("Sentiment Analysis Output:")
|
22 |
st.text(output[0][0]['label'])
|
23 |
|
|
|
1 |
+
# import os
|
2 |
+
# import matplotlib
|
3 |
+
# matplotlib.use('Agg') # Use the 'Agg' backend for non-interactive use
|
4 |
+
# import streamlit as st
|
5 |
+
# import tkinter as tk
|
6 |
+
# from tkinter import scrolledtext
|
7 |
+
# import requests
|
8 |
+
|
9 |
+
# SECRET_TOKEN = os.getenv("SECRET_TOKEN")
|
10 |
+
|
11 |
+
# API_URL = "https://api-inference.huggingface.co/models/ahmedrachid/FinancialBERT-Sentiment-Analysis"
|
12 |
+
# headers = {"Authorization": f"Bearer {SECRET_TOKEN}"}
|
13 |
+
|
14 |
+
# def query(payload):
|
15 |
+
# response = requests.post(API_URL, headers=headers, json=payload)
|
16 |
+
# return response.json()
|
17 |
+
|
18 |
+
# user_query = st.text_area("Enter your text:")
|
19 |
+
# if st.button("Analyze Sentiment"):
|
20 |
+
# output = query({"inputs": user_query})
|
21 |
+
# st.text("Sentiment Analysis Output:")
|
22 |
+
# st.text(output[0][0]['label'])
|
23 |
+
|
24 |
+
|
25 |
import os
|
|
|
|
|
26 |
import streamlit as st
|
|
|
|
|
27 |
import requests
|
28 |
|
29 |
SECRET_TOKEN = os.getenv("SECRET_TOKEN")
|
|
|
37 |
|
38 |
user_query = st.text_area("Enter your text:")
|
39 |
if st.button("Analyze Sentiment"):
|
40 |
+
# Show loading message while the model is loading
|
41 |
+
with st.spinner("Analyzing..."):
|
42 |
+
# Load the model
|
43 |
+
output = query({"inputs": user_query})
|
44 |
+
|
45 |
+
# Display results after loading
|
46 |
st.text("Sentiment Analysis Output:")
|
47 |
st.text(output[0][0]['label'])
|
48 |
|