File size: 3,281 Bytes
674526c
 
 
 
4cedea7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
674526c
 
 
 
 
 
 
 
 
 
 
 
4cedea7
674526c
 
 
 
4cedea7
674526c
 
4cedea7
674526c
 
 
 
 
 
 
 
 
4cedea7
674526c
 
 
 
 
 
 
 
 
4cedea7
674526c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4cedea7
674526c
 
 
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import streamlit as st
from PIL import Image
import requests

# Dummy functions to simulate the behavior of the removed pipelines
def summarize(text):
    return "This is a summary of the text."

def detect_age(image):
    return "Age: 25-30"

def classify_image(image, candidate_labels):
    return [{"label": label, "score": 0.5} for label in candidate_labels]

def detect_emotion(text):
    return "joy"

def translate(text):
    return "Ceci est une traduction."

st.title("NLP APP")
option = st.sidebar.selectbox(
    "Choose a task",
    ("Summarization", "Age Detection", "Emotion Detection", "Image Classification", "Translation")
)

if option == "Summarization":
    st.title("Text Summarization")
    text = st.text_area("Enter text to summarize")
    if st.button("Summarize"):
        if text:
            st.write("Summary:", summarize(text))
        else:
            st.write("Please enter text to summarize.")
elif option == "Age Detection":
    st.title("Welcome to age detection")
    uploaded_files = st.file_uploader("Choose an image file", type="jpg")
    if uploaded_files is not None:
        image = Image.open(uploaded_files)
        st.write(detect_age(image))
elif option == "Image Classification":
    st.title("Welcome to object detection")
    uploaded_file = st.file_uploader("Choose an image file", type=["jpg", "jpeg", "png"])
    text = st.text_area("Enter possible class names (comma-separated)")
    if st.button("Submit"):
        if uploaded_file is not None and text:
            candidate_labels = [t.strip() for t in text.split(',')]
            image = Image.open(uploaded_file)
            st.image(image, caption="Uploaded Image", use_column_width=True)
            classification_result = classify_image(image, candidate_labels)
            for result in classification_result:
                st.write(f"Label: {result['label']}, Score: {result['score']}")
        else:
            st.write("Please upload an image file and enter class names.")
elif option == "Emotion Detection":
    st.title("Detect your emotion")
    text = st.text_area("Enter your text")
    if st.button("Submit"):
        if text:
            emotion = detect_emotion(text)
            if emotion == "sadness":
                st.write("Emotion : ", emotion, "😒")
            elif emotion == "joy":
                st.write("Emotion : ", emotion, "πŸ˜ƒ")
            elif emotion == "fear":
                st.write("Emotion : ", emotion, "😨")
            elif emotion == "anger":
                st.write("Emotion : ", emotion, "😑")
            elif emotion == "neutral":
                st.write("Emotion : ", emotion, "😐")
            elif emotion == "disgust":
                st.write("Emotion : ", emotion, "🀒")
            elif emotion == "surprise":
                st.write("Emotion : ", emotion, "😲")
        else:
            st.write("Please enter text.")
elif option == "Translation":
    st.title("Text Translation")
    text = st.text_area("Enter text to translate from English to French")
    if st.button("Translate"):
        if text:
            translation = translate(text)
            st.write("Translation:", translation)
        else:
            st.write("Please enter text to translate.")
else:
    st.title("None")