vm567 commited on
Commit
87526d4
1 Parent(s): 6725132

added streamlit application code

Browse files
Files changed (3) hide show
  1. README.md +9 -0
  2. app.py +20 -0
  3. requirements.txt +0 -0
README.md CHANGED
@@ -23,3 +23,12 @@ things that will be using in this project -
23
  github.com tpo host the code base
24
  hugging stream face - to host the web application
25
  github.dev - to edit the code base
 
 
 
 
 
 
 
 
 
 
23
  github.com tpo host the code base
24
  hugging stream face - to host the web application
25
  github.dev - to edit the code base
26
+
27
+
28
+ process - write code - push to github - then the codebase to be deployed to hugging face
29
+
30
+ Code
31
+ - created a virtual env to install necessary libraries ( in vscode use command ctrl+shift+p and enter python create environment) vscode automatically creates a virtual environment for us
32
+ - install necessary libraries
33
+ - write all the libraries in a file (cmnd pip freeze > requirements.txt)
34
+ - create a file name app.py
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Load the sentiment analysis model from Hugging Face
5
+ classifier = pipeline('sentiment-analysis')
6
+
7
+ # Create a Streamlit app
8
+ st.title('Sentiment Analysis with Hugging Face')
9
+ st.write('Enter some text and we will predict its sentiment!')
10
+
11
+ # Add a text input box for the user to enter text
12
+ text_input = st.text_input('Enter text here')
13
+
14
+ # When the user submits text, run the sentiment analysis model on it
15
+ if st.button('Submit'):
16
+ # Predict the sentiment of the text using the Hugging Face model
17
+ sentiment = classifier(text_input)[0]['label']
18
+
19
+ # Display the sentiment prediction to the user
20
+ st.write(f'Sentiment: {sentiment}')
requirements.txt ADDED
Binary file (78 Bytes). View file