Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import os
|
2 |
import matplotlib
|
3 |
-
# This MUST be at the top, before any other matplotlib imports
|
4 |
os.environ['MPLCONFIGDIR'] = '/tmp'
|
5 |
|
6 |
import streamlit as st
|
@@ -16,6 +15,7 @@ import plotly.graph_objects as go
|
|
16 |
import plotly.express as px
|
17 |
from streamlit_lottie import st_lottie
|
18 |
import random
|
|
|
19 |
|
20 |
# Configuration de la page
|
21 |
st.set_page_config(
|
@@ -25,71 +25,6 @@ st.set_page_config(
|
|
25 |
initial_sidebar_state="expanded"
|
26 |
)
|
27 |
|
28 |
-
def load_lottieurl(url: str):
|
29 |
-
r = requests.get(url)
|
30 |
-
if r.status_code != 200:
|
31 |
-
return None
|
32 |
-
return r.json()
|
33 |
-
|
34 |
-
# Use a new Lottie URL and add a check
|
35 |
-
lottie_url = "https://assets5.lottiefiles.com/packages/lf20_V9t630.json"
|
36 |
-
lottie_animation = load_lottieurl(lottie_url)
|
37 |
-
|
38 |
-
if lottie_animation:
|
39 |
-
st_lottie(
|
40 |
-
lottie_animation,
|
41 |
-
speed=1,
|
42 |
-
reverse=False,
|
43 |
-
loop=True,
|
44 |
-
quality="low",
|
45 |
-
height=200,
|
46 |
-
width=200,
|
47 |
-
key=None,
|
48 |
-
)
|
49 |
-
|
50 |
-
st.title("API de NLU pour le Dialecte Marocain (Darija)")
|
51 |
-
|
52 |
-
st.write("Cette API a été développée en utilisant des modèles de pointe pour la reconnaissance d'entités nommées (NER) et la classification de sentiments en Darija.")
|
53 |
-
st.write("Le modèle NER est capable d'identifier les entités telles que les personnes, les organisations, les lieux et les dates, tandis que le modèle de classification de sentiments peut déterminer si un texte donné a une connotation positive, négative ou neutre.")
|
54 |
-
|
55 |
-
st.sidebar.title("Navigation")
|
56 |
-
page = st.sidebar.radio("Aller à", ["NER", "Classification de Sentiments"])
|
57 |
-
|
58 |
-
if page == "NER":
|
59 |
-
st.header("Reconnaissance d'Entités Nommées (NER)")
|
60 |
-
text_ner = st.text_area("Entrez un texte en Darija pour la NER")
|
61 |
-
if st.button("Prédire NER"):
|
62 |
-
if text_ner:
|
63 |
-
with st.spinner('Prédiction en cours...'):
|
64 |
-
time.sleep(2)
|
65 |
-
response = requests.post("http://3.80.153.76:8080/ner", json={"text": text_ner})
|
66 |
-
if response.status_code == 200:
|
67 |
-
st.success("Prédiction NER réussie!")
|
68 |
-
st.json(response.json())
|
69 |
-
else:
|
70 |
-
st.error("Erreur lors de la prédiction NER.")
|
71 |
-
else:
|
72 |
-
st.warning("Veuillez entrer un texte pour la NER.")
|
73 |
-
|
74 |
-
elif page == "Classification de Sentiments":
|
75 |
-
st.header("Classification de Sentiments")
|
76 |
-
text_sent = st.text_area("Entrez un texte en Darija pour la classification de sentiments")
|
77 |
-
if st.button("Prédire Sentiment"):
|
78 |
-
if text_sent:
|
79 |
-
with st.spinner('Prédiction en cours...'):
|
80 |
-
time.sleep(2)
|
81 |
-
response = requests.post("http://3.80.153.76:8080/sentiment", json={"text": text_sent})
|
82 |
-
if response.status_code == 200:
|
83 |
-
st.success("Prédiction de sentiment réussie!")
|
84 |
-
st.json(response.json())
|
85 |
-
else:
|
86 |
-
st.error("Erreur lors de la prédiction de sentiment.")
|
87 |
-
else:
|
88 |
-
st.warning("Veuillez entrer un texte pour la classification de sentiments.")
|
89 |
-
|
90 |
-
st.sidebar.markdown("---")
|
91 |
-
st.sidebar.info("Développé par Mohammed MEDIANI")
|
92 |
-
|
93 |
# Fonctions utilitaires
|
94 |
def call_api(text):
|
95 |
"""Appelle l'API NLU Darija et retourne le résultat"""
|
|
|
1 |
import os
|
2 |
import matplotlib
|
|
|
3 |
os.environ['MPLCONFIGDIR'] = '/tmp'
|
4 |
|
5 |
import streamlit as st
|
|
|
15 |
import plotly.express as px
|
16 |
from streamlit_lottie import st_lottie
|
17 |
import random
|
18 |
+
from streamlit_lottie import st_lottie # Note: this is duplicated
|
19 |
|
20 |
# Configuration de la page
|
21 |
st.set_page_config(
|
|
|
25 |
initial_sidebar_state="expanded"
|
26 |
)
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
# Fonctions utilitaires
|
29 |
def call_api(text):
|
30 |
"""Appelle l'API NLU Darija et retourne le résultat"""
|