img10 / app (3).py
chayanee's picture
Upload 2 files
c3ad358
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()