Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Jan Mühlnikel
commited on
Commit
·
948d7f1
1
Parent(s):
e8954be
added bautifications
Browse files
__pycache__/similarity_page.cpython-310.pyc
CHANGED
Binary files a/__pycache__/similarity_page.cpython-310.pyc and b/__pycache__/similarity_page.cpython-310.pyc differ
|
|
functions/__pycache__/semantic_search.cpython-310.pyc
CHANGED
Binary files a/functions/__pycache__/semantic_search.cpython-310.pyc and b/functions/__pycache__/semantic_search.cpython-310.pyc differ
|
|
modules/__pycache__/result_table.cpython-310.pyc
CHANGED
Binary files a/modules/__pycache__/result_table.cpython-310.pyc and b/modules/__pycache__/result_table.cpython-310.pyc differ
|
|
modules/result_table.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
import pandas as pd
|
3 |
|
4 |
def show_table(p1_df, p2_df):
|
@@ -7,24 +8,44 @@ def show_table(p1_df, p2_df):
|
|
7 |
p1_df = p1_df.reset_index(drop=True)
|
8 |
p2_df = p2_df.reset_index(drop=True)
|
9 |
|
10 |
-
|
|
|
|
|
11 |
match_df = pd.DataFrame()
|
12 |
row_from_p1 = p1_df.iloc[[i]]
|
13 |
row_from_p2 = p2_df.iloc[[i]]
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
# Correctly append rows to match_df
|
|
|
|
|
16 |
match_df = pd.concat([row_from_p1, row_from_p2], ignore_index=True)
|
17 |
|
|
|
|
|
|
|
|
|
18 |
st.dataframe(
|
19 |
-
match_df[["
|
20 |
use_container_width = True,
|
21 |
height = 35 + 35 * len(match_df),
|
22 |
column_config={
|
|
|
23 |
"similarity": st.column_config.TextColumn(
|
24 |
"Similarity",
|
25 |
help="simialrity",
|
26 |
disabled=True
|
27 |
),
|
|
|
28 |
"iati_id": st.column_config.TextColumn(
|
29 |
"IATI ID",
|
30 |
help="IATI Project ID",
|
@@ -55,20 +76,17 @@ def show_table(p1_df, p2_df):
|
|
55 |
help="Country of project",
|
56 |
disabled=True
|
57 |
),
|
58 |
-
"
|
59 |
"SDG Prediction",
|
60 |
help="Prediction of SDG's",
|
61 |
-
disabled=True
|
62 |
),
|
63 |
-
"
|
64 |
"CRS 3",
|
65 |
help="CRS 3 code given by organization",
|
66 |
-
disabled=True
|
67 |
),
|
68 |
-
"
|
69 |
"CRS 5",
|
70 |
-
help="CRS 5 code given by organization"
|
71 |
-
disabled=True
|
72 |
),
|
73 |
},
|
74 |
hide_index=True,
|
|
|
1 |
import streamlit as st
|
2 |
+
from st_aggrid import AgGrid, GridOptionsBuilder
|
3 |
import pandas as pd
|
4 |
|
5 |
def show_table(p1_df, p2_df):
|
|
|
8 |
p1_df = p1_df.reset_index(drop=True)
|
9 |
p2_df = p2_df.reset_index(drop=True)
|
10 |
|
11 |
+
actual_ind = 0
|
12 |
+
for i in range(len(p1_df) - 1, -1, -2): # stepsize because project matchs in both ways and it should only display a match one time
|
13 |
+
actual_ind += 1
|
14 |
match_df = pd.DataFrame()
|
15 |
row_from_p1 = p1_df.iloc[[i]]
|
16 |
row_from_p2 = p2_df.iloc[[i]]
|
17 |
|
18 |
+
# transform strings to list
|
19 |
+
row_from_p1["crs_3_code_list"] = [row_from_p1['crs_3_code'].item().split(";")[:-1]]
|
20 |
+
row_from_p2["crs_3_code_list"] = [row_from_p2['crs_3_code'].item().split(";")[:-1]]
|
21 |
+
|
22 |
+
row_from_p1["crs_5_code_list"] = [row_from_p1['crs_3_code'].item().split(";")[:-1]]
|
23 |
+
row_from_p2["crs_5_code_list"] = [row_from_p2['crs_3_code'].item().split(";")[:-1]]
|
24 |
+
|
25 |
+
row_from_p1["sdg_list"] = [row_from_p1['sgd_pred_code'].item()]
|
26 |
+
row_from_p2["sdg_list"] = [row_from_p2['sgd_pred_code'].item()]
|
27 |
+
|
28 |
# Correctly append rows to match_df
|
29 |
+
st.subheader(f"#{actual_ind}")
|
30 |
+
st.caption(f"Similarity: {round(row_from_p1['similarity'].item(), 4) * 100}%")
|
31 |
match_df = pd.concat([row_from_p1, row_from_p2], ignore_index=True)
|
32 |
|
33 |
+
|
34 |
+
|
35 |
+
#AgGrid(match_df)
|
36 |
+
|
37 |
st.dataframe(
|
38 |
+
match_df[["iati_id", "title_main", "orga_abbreviation", "client", "description_main", "country", "sdg_list", "crs_3_code_list", "crs_5_code_list"]],
|
39 |
use_container_width = True,
|
40 |
height = 35 + 35 * len(match_df),
|
41 |
column_config={
|
42 |
+
"""
|
43 |
"similarity": st.column_config.TextColumn(
|
44 |
"Similarity",
|
45 |
help="simialrity",
|
46 |
disabled=True
|
47 |
),
|
48 |
+
"""
|
49 |
"iati_id": st.column_config.TextColumn(
|
50 |
"IATI ID",
|
51 |
help="IATI Project ID",
|
|
|
76 |
help="Country of project",
|
77 |
disabled=True
|
78 |
),
|
79 |
+
"sdg_list": st.column_config.ListColumn(
|
80 |
"SDG Prediction",
|
81 |
help="Prediction of SDG's",
|
|
|
82 |
),
|
83 |
+
"crs_3_code_list": st.column_config.ListColumn(
|
84 |
"CRS 3",
|
85 |
help="CRS 3 code given by organization",
|
|
|
86 |
),
|
87 |
+
"crs_5_code_list": st.column_config.ListColumn(
|
88 |
"CRS 5",
|
89 |
+
help="CRS 5 code given by organization"
|
|
|
90 |
),
|
91 |
},
|
92 |
hide_index=True,
|
requirements.txt
CHANGED
@@ -5,4 +5,5 @@ streamlit-option-menu==0.3.12
|
|
5 |
scipy==1.12.0
|
6 |
faiss-cpu==1.8.0
|
7 |
faiss-gpu==1.7.2
|
8 |
-
sentence-transformers==2.5.1
|
|
|
|
5 |
scipy==1.12.0
|
6 |
faiss-cpu==1.8.0
|
7 |
faiss-gpu==1.7.2
|
8 |
+
sentence-transformers==2.5.1
|
9 |
+
streamlit-aggrid==0.3.4.
|
similarity_page.py
CHANGED
@@ -9,7 +9,6 @@ import streamlit as st
|
|
9 |
import pandas as pd
|
10 |
from scipy.sparse import load_npz
|
11 |
import pickle
|
12 |
-
import faiss
|
13 |
from sentence_transformers import SentenceTransformer
|
14 |
from modules.result_table import show_table
|
15 |
from functions.filter_projects import filter_projects
|
@@ -129,7 +128,6 @@ COUNTRY_OPTION_LIST = getCountry()
|
|
129 |
# LOAD MODEL FROM CACHE FO SEMANTIC SEARCH
|
130 |
model = load_model()
|
131 |
embeddings = load_embeddings_and_index()
|
132 |
-
#embeddings = []
|
133 |
|
134 |
def show_page():
|
135 |
st.write(f"Current RAM usage of this app: {get_process_memory():.2f} MB")
|
|
|
9 |
import pandas as pd
|
10 |
from scipy.sparse import load_npz
|
11 |
import pickle
|
|
|
12 |
from sentence_transformers import SentenceTransformer
|
13 |
from modules.result_table import show_table
|
14 |
from functions.filter_projects import filter_projects
|
|
|
128 |
# LOAD MODEL FROM CACHE FO SEMANTIC SEARCH
|
129 |
model = load_model()
|
130 |
embeddings = load_embeddings_and_index()
|
|
|
131 |
|
132 |
def show_page():
|
133 |
st.write(f"Current RAM usage of this app: {get_process_memory():.2f} MB")
|