Saliou-Ndim commited on
Commit
bbb0d01
·
verified ·
1 Parent(s): 6cd06f0

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +29 -29
src/streamlit_app.py CHANGED
@@ -1,7 +1,3 @@
1
- import altair as alt
2
- import numpy as np
3
- import pandas as pd
4
- import streamlit as st
5
 
6
  """
7
  # Welcome to Streamlit!
@@ -12,29 +8,33 @@ forums](https://discuss.streamlit.io).
12
 
13
  In the meantime, below is an example of what you can do with just a few lines of code:
14
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
18
-
19
- indices = np.linspace(0, 1, num_points)
20
- theta = 2 * np.pi * num_turns * indices
21
- radius = indices
22
-
23
- x = radius * np.cos(theta)
24
- y = radius * np.sin(theta)
25
-
26
- df = pd.DataFrame({
27
- "x": x,
28
- "y": y,
29
- "idx": indices,
30
- "rand": np.random.randn(num_points),
31
- })
32
-
33
- st.altair_chart(alt.Chart(df, height=700, width=700)
34
- .mark_point(filled=True)
35
- .encode(
36
- x=alt.X("x", axis=None),
37
- y=alt.Y("y", axis=None),
38
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
40
- ))
 
 
 
 
 
1
 
2
  """
3
  # Welcome to Streamlit!
 
8
 
9
  In the meantime, below is an example of what you can do with just a few lines of code:
10
  """
11
+ import threading
12
+ import subprocess
13
+
14
+ def run_fastapi():
15
+ subprocess.run(["uvicorn", "src.api:app", "--host", "0.0.0.0", "--port", "8000"])
16
+
17
+ threading.Thread(target=run_fastapi, daemon=True).start()
18
+
19
+ # Ensuite ton app Streamlit continue ici
20
+ import streamlit as st
21
+
22
+ st.title("🌍 Prédiction Langue & Type")
23
+
24
+ user_input = st.text_area("✍🏽 Entrez votre texte ici", height=150)
25
+
26
+ if st.button("Prédire"):
27
+ import requests
28
+ import json
29
+ response = requests.post(
30
+ "http://localhost:8000/predict",
31
+ json={"texts": [user_input]}
32
+ )
33
+ prediction = response.json()[0]
34
+
35
+ st.success(f"🔤 Langue : {prediction['lang']['label']} ({prediction['lang']['confidence']})")
36
+ st.info(f"❓ Type : {prediction['type']['label']} ({prediction['type']['confidence']})")
37
 
38
+ with st.expander("🔎 Détails des probabilités"):
39
+ st.write("📊 Langue :", prediction["lang"]["distribution"])
40
+ st.write("📊 Type :", prediction["type"]["distribution"])