KishanKumar001
commited on
Commit
·
010a8fb
1
Parent(s):
ace7b0f
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import os
|
2 |
import matplotlib
|
3 |
matplotlib.use('Agg') # Use the 'Agg' backend for non-interactive use
|
|
|
4 |
import tkinter as tk
|
5 |
from tkinter import scrolledtext
|
6 |
import requests
|
@@ -14,31 +15,20 @@ def query(payload):
|
|
14 |
response = requests.post(API_URL, headers=headers, json=payload)
|
15 |
return response.json()
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
def get_user_input():
|
18 |
user_query = user_input.get("1.0", tk.END).strip()
|
19 |
output_text.delete(1.0, tk.END) # Clear previous output
|
20 |
output = query({"inputs": user_query})
|
21 |
output_text.insert(tk.END, output)
|
22 |
|
23 |
-
window = tk.Tk()
|
24 |
-
window.title("Hugging Face Sentiment Analysis")
|
25 |
-
|
26 |
-
user_input_label = tk.Label(window, text="Enter your text:")
|
27 |
-
user_input_label.pack()
|
28 |
-
|
29 |
-
user_input = scrolledtext.ScrolledText(window, width=40, height=5, wrap=tk.WORD)
|
30 |
-
user_input.pack()
|
31 |
-
|
32 |
-
query_button = tk.Button(window, text="Analyze Sentiment", command=get_user_input)
|
33 |
-
query_button.pack()
|
34 |
-
|
35 |
-
output_text_label = tk.Label(window, text="Sentiment Analysis Output:")
|
36 |
-
output_text_label.pack()
|
37 |
|
38 |
-
output_text = scrolledtext.ScrolledText(window, width=40, height=10, wrap=tk.WORD)
|
39 |
-
output_text.pack()
|
40 |
|
41 |
-
window.mainloop()
|
42 |
|
43 |
|
44 |
|
|
|
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
|
|
|
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)
|
23 |
+
|
24 |
def get_user_input():
|
25 |
user_query = user_input.get("1.0", tk.END).strip()
|
26 |
output_text.delete(1.0, tk.END) # Clear previous output
|
27 |
output = query({"inputs": user_query})
|
28 |
output_text.insert(tk.END, output)
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
|
|
|
|
31 |
|
|
|
32 |
|
33 |
|
34 |
|