chayanee commited on
Commit
197c55a
·
1 Parent(s): c3ad358

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +33 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image
3
+ import pandas as pd
4
+ from transformers import pipeline
5
+
6
+ # Create a sentiment analysis pipeline
7
+ sentiment_analysis = pipeline("sentiment-analysis", model="chayanee/Detected_img")
8
+
9
+ # Set the title for your Streamlit app
10
+ st.title("NLP and Image Analysis")
11
+
12
+ # Text Input Widget
13
+ text_input = st.text_area("Enter some text for sentiment analysis:")
14
+
15
+ # Image Upload Widget
16
+ uploaded_image = st.file_uploader("Upload an image for analysis", type=["jpg", "jpeg", "png"])
17
+
18
+ # Perform sentiment analysis when the user clicks a button
19
+ if st.button("Analyze"):
20
+ # Perform sentiment analysis on the text
21
+ if text_input:
22
+ sentiment_result = sentiment_analysis(text_input)
23
+ st.write("Sentiment Analysis Result:")
24
+ st.write(sentiment_result)
25
+
26
+ # Analyze the uploaded image if available
27
+ if uploaded_image:
28
+ # Display the uploaded image
29
+ image = Image.open(uploaded_image)
30
+ st.image(image, caption="Uploaded Image", use_column_width=True)
31
+
32
+ if __name__ == "__main__":
33
+ main()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ torch
2
+ transformers
3
+ altair<5