KishanKumar001's picture
Update app.py
7c09551
# import os
# import matplotlib
# matplotlib.use('Agg') # Use the 'Agg' backend for non-interactive use
# import streamlit as st
# import tkinter as tk
# from tkinter import scrolledtext
# import requests
# SECRET_TOKEN = os.getenv("SECRET_TOKEN")
# API_URL = "/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2Fahmedrachid%2FFinancialBERT-Sentiment-Analysis%26quot%3B%3C%2Fspan%3E%3C!-- HTML_TAG_END -->
# headers = {"Authorization": f"Bearer {SECRET_TOKEN}"}
# def query(payload):
# response = requests.post(API_URL, headers=headers, json=payload)
# return response.json()
# user_query = st.text_area("Enter your text:")
# if st.button("Analyze Sentiment"):
# output = query({"inputs": user_query})
# st.text("Sentiment Analysis Output:")
# st.text(output[0][0]['label'])
import os
import streamlit as st
import requests
SECRET_TOKEN = os.getenv("SECRET_TOKEN")
API_URL = "/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2Fahmedrachid%2FFinancialBERT-Sentiment-Analysis%26quot%3B%3C%2Fspan%3E%3C!-- HTML_TAG_END -->
headers = {"Authorization": f"Bearer {SECRET_TOKEN}"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
user_query = st.text_area("Enter your text:")
if st.button("Analyze Sentiment"):
# Show loading message while the model is loading
with st.spinner("Analyzing..."):
# Load the model
output = query({"inputs": user_query})
# Display results after loading
st.text("Sentiment Analysis Output:")
st.text(output[0][0]['label'])