File size: 1,056 Bytes
c3ad358
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import streamlit as st
from PIL import Image
import pandas as pd
from transformers import pipeline

# Create a sentiment analysis pipeline
sentiment_analysis = pipeline("sentiment-analysis", model="chayanee/Detected_img")

# Set the title for your Streamlit app
st.title("NLP and Image Analysis")

# Text Input Widget
text_input = st.text_area("Enter some text for sentiment analysis:")

# Image Upload Widget
uploaded_image = st.file_uploader("Upload an image for analysis", type=["jpg", "jpeg", "png"])

# Perform sentiment analysis when the user clicks a button
if st.button("Analyze"):
    # Perform sentiment analysis on the text
    if text_input:
        sentiment_result = sentiment_analysis(text_input)
        st.write("Sentiment Analysis Result:")
        st.write(sentiment_result)

    # Analyze the uploaded image if available
    if uploaded_image:
        # Display the uploaded image
        image = Image.open(uploaded_image)
        st.image(image, caption="Uploaded Image", use_column_width=True)

if __name__ == "__main__":
    main()