Spaces:
No application file
No application file
Upload app (3).py
Browse files- app (3).py +20 -23
app (3).py
CHANGED
|
@@ -1,36 +1,33 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from PIL import Image
|
| 3 |
-
from io import StringIO
|
| 4 |
import pandas as pd
|
| 5 |
from transformers import pipeline
|
| 6 |
|
| 7 |
-
# Create
|
| 8 |
-
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
st.image(uploaded_file, caption="Uploaded Image", use_column_width=True)
|
| 19 |
-
|
| 20 |
-
# Perform object detection
|
| 21 |
-
image = Image.open(uploaded_file)
|
| 22 |
-
results = classifier(image)
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
st.image(image.crop(box), caption=f"Object: {label}", use_column_width=True)
|
| 32 |
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
if __name__ == "__main__":
|
| 36 |
main()
|
|
|
|
| 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()
|