Balnur26 commited on
Commit
debe366
·
1 Parent(s): b7d7047

added code

Browse files
Files changed (4) hide show
  1. .gitattributes +4 -0
  2. .gitignore +2 -0
  3. app.py +35 -0
  4. requirements.txt +0 -0
.gitattributes CHANGED
@@ -33,3 +33,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ hfTest/Lib/site-packages/numpy.libs/libscipy_openblas64_-43e11ff0749b8cbe0a615c9cf6737e0e.dll filter=lfs diff=lfs merge=lfs -text
37
+ hfTest/Lib/site-packages/pyarrow/arrow.dll filter=lfs diff=lfs merge=lfs -text
38
+ hfTest/Lib/site-packages/pyarrow/arrow_flight.dll filter=lfs diff=lfs merge=lfs -text
39
+ hfTest/Lib/site-packages/pydeck/nbextension/static/index.js.map filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ hfTest/
2
+ .vscode
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Application title
5
+ st.title("Text Sentiment Analysis App")
6
+ st.write("Analyze whether a given text is positive or negative using a Hugging Face model.")
7
+
8
+ # Text input
9
+ user_input = st.text_area("Enter your text:", placeholder="For example: I love this product!")
10
+
11
+ # Initialize the model
12
+ @st.cache_resource
13
+ def load_sentiment_model():
14
+ return pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
15
+
16
+ # Load the model
17
+ model = load_sentiment_model()
18
+
19
+ # Perform analysis if input is provided
20
+ if st.button("Analyze"):
21
+ if user_input.strip():
22
+ with st.spinner("Analyzing sentiment..."):
23
+ result = model(user_input)
24
+ st.success("Analysis complete!")
25
+
26
+ # Extracting the label and score
27
+ label = result[0]['label']
28
+ score = result[0]['score']
29
+
30
+ # Display the result
31
+ st.write(f"**Label:** {label}")
32
+ st.write(f"**Confidence Score:** {score:.2f}")
33
+
34
+ else:
35
+ st.error("Please enter some text!")
requirements.txt ADDED
File without changes