Spaces:
Sleeping
Sleeping
cache data for map
Browse files
app.py
CHANGED
|
@@ -10,7 +10,6 @@ from safetensors import safe_open
|
|
| 10 |
from sentence_transformers import SentenceTransformer
|
| 11 |
|
| 12 |
from semantic_search import predict
|
| 13 |
-
from utils.process_data import add_coor, load_data, merge_geoemtry
|
| 14 |
|
| 15 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 16 |
CITIES_ENRICHED = os.path.join("data", "cities_enriched_manually.csv")
|
|
@@ -151,10 +150,9 @@ fig = go.Figure(
|
|
| 151 |
fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))
|
| 152 |
fig.update_layout(height=1000, width=1000, template="plotly")
|
| 153 |
|
|
|
|
| 154 |
# load data ready to plot for local testing
|
| 155 |
-
|
| 156 |
-
germany["lat"] = pd.to_numeric(germany["lat"])
|
| 157 |
-
germany["lon"] = pd.to_numeric(germany["lon"])
|
| 158 |
# germany.drop(columns=["lat", "lon"], inplace=True)
|
| 159 |
|
| 160 |
# # or generate it directly in this script
|
|
@@ -164,6 +162,34 @@ germany["lon"] = pd.to_numeric(germany["lon"])
|
|
| 164 |
# germany.to_csv(MAP_PATH_WITH_COORD, index=False)
|
| 165 |
|
| 166 |
# # germany need columns with lat and lon as well as hover data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
fig_map = px.scatter_geo(
|
| 168 |
germany,
|
| 169 |
lat="lat",
|
|
@@ -199,20 +225,6 @@ fig_map.update_layout(
|
|
| 199 |
height=700,
|
| 200 |
)
|
| 201 |
|
| 202 |
-
tensors = {}
|
| 203 |
-
with safe_open("corpus_embeddings.pt", framework="pt", device="cpu") as f:
|
| 204 |
-
for k in f.keys():
|
| 205 |
-
tensors[k] = f.get_tensor(k)
|
| 206 |
-
|
| 207 |
-
model = SentenceTransformer(
|
| 208 |
-
model_name_or_path="and-effect/musterdatenkatalog_clf",
|
| 209 |
-
device="cpu",
|
| 210 |
-
use_auth_token=HF_TOKEN,
|
| 211 |
-
)
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
st.set_page_config(layout="wide")
|
| 215 |
-
|
| 216 |
st.title("Musterdatenkatalog (MDK)")
|
| 217 |
|
| 218 |
st.markdown(
|
|
|
|
| 10 |
from sentence_transformers import SentenceTransformer
|
| 11 |
|
| 12 |
from semantic_search import predict
|
|
|
|
| 13 |
|
| 14 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 15 |
CITIES_ENRICHED = os.path.join("data", "cities_enriched_manually.csv")
|
|
|
|
| 150 |
fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))
|
| 151 |
fig.update_layout(height=1000, width=1000, template="plotly")
|
| 152 |
|
| 153 |
+
|
| 154 |
# load data ready to plot for local testing
|
| 155 |
+
|
|
|
|
|
|
|
| 156 |
# germany.drop(columns=["lat", "lon"], inplace=True)
|
| 157 |
|
| 158 |
# # or generate it directly in this script
|
|
|
|
| 162 |
# germany.to_csv(MAP_PATH_WITH_COORD, index=False)
|
| 163 |
|
| 164 |
# # germany need columns with lat and lon as well as hover data
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
tensors = {}
|
| 168 |
+
with safe_open("corpus_embeddings.pt", framework="pt", device="cpu") as f:
|
| 169 |
+
for k in f.keys():
|
| 170 |
+
tensors[k] = f.get_tensor(k)
|
| 171 |
+
|
| 172 |
+
model = SentenceTransformer(
|
| 173 |
+
model_name_or_path="and-effect/musterdatenkatalog_clf",
|
| 174 |
+
device="cpu",
|
| 175 |
+
use_auth_token=HF_TOKEN,
|
| 176 |
+
)
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
st.set_page_config(layout="wide")
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
@st.cache_data
|
| 183 |
+
def load_data() -> pd.DataFrame:
|
| 184 |
+
germany = pd.read_csv(MAP_PATH)
|
| 185 |
+
return germany
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
germany = load_data()
|
| 189 |
+
germany["lat"] = pd.to_numeric(germany["lat"])
|
| 190 |
+
germany["lon"] = pd.to_numeric(germany["lon"])
|
| 191 |
+
|
| 192 |
+
|
| 193 |
fig_map = px.scatter_geo(
|
| 194 |
germany,
|
| 195 |
lat="lat",
|
|
|
|
| 225 |
height=700,
|
| 226 |
)
|
| 227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
st.title("Musterdatenkatalog (MDK)")
|
| 229 |
|
| 230 |
st.markdown(
|