Spaces:
Running
Running
Commit
·
7ba815c
1
Parent(s):
d362bcf
quick fixes
Browse files- app.py +4 -3
- requirements.txt +1 -1
- st_utils.py +2 -2
app.py
CHANGED
@@ -3,6 +3,7 @@ from st_utils import bm25_search, semantic_search, hf_api, paginator
|
|
3 |
from huggingface_hub import ModelSearchArguments
|
4 |
import webbrowser
|
5 |
from numerize.numerize import numerize
|
|
|
6 |
|
7 |
st.set_page_config(
|
8 |
page_title="HF Search Engine",
|
@@ -17,7 +18,7 @@ search_backend = st.sidebar.selectbox(
|
|
17 |
["semantic", "bm25", "hfapi"],
|
18 |
format_func=lambda x: {"hfapi": "Keyword search", "bm25": "BM25 search", "semantic": "Semantic Search"}[x],
|
19 |
)
|
20 |
-
limit_results = st.sidebar.number_input("Limit results", min_value=0, value=10)
|
21 |
|
22 |
st.sidebar.markdown("# Filters")
|
23 |
args = ModelSearchArguments()
|
@@ -74,8 +75,8 @@ if search_query != "":
|
|
74 |
):
|
75 |
col1, col2, col3 = st.columns([5, 1, 1])
|
76 |
col1.metric("Model", hit["modelId"])
|
77 |
-
col2.metric("N° downloads", numerize(hit["downloads"]))
|
78 |
-
col3.metric("N° likes", numerize(hit["likes"]))
|
79 |
st.button(
|
80 |
f"View model on 🤗",
|
81 |
on_click=lambda hit=hit: webbrowser.open(f"https://huggingface.co/{hit['modelId']}"),
|
|
|
3 |
from huggingface_hub import ModelSearchArguments
|
4 |
import webbrowser
|
5 |
from numerize.numerize import numerize
|
6 |
+
import math
|
7 |
|
8 |
st.set_page_config(
|
9 |
page_title="HF Search Engine",
|
|
|
18 |
["semantic", "bm25", "hfapi"],
|
19 |
format_func=lambda x: {"hfapi": "Keyword search", "bm25": "BM25 search", "semantic": "Semantic Search"}[x],
|
20 |
)
|
21 |
+
limit_results = int(st.sidebar.number_input("Limit results", min_value=0, value=10))
|
22 |
|
23 |
st.sidebar.markdown("# Filters")
|
24 |
args = ModelSearchArguments()
|
|
|
75 |
):
|
76 |
col1, col2, col3 = st.columns([5, 1, 1])
|
77 |
col1.metric("Model", hit["modelId"])
|
78 |
+
col2.metric("N° downloads", numerize(hit["downloads"]) if not math.isnan(hit["downloads"]) else "N/A")
|
79 |
+
col3.metric("N° likes", numerize(hit["likes"]) if not math.isnan(hit["likes"]) else "N/A")
|
80 |
st.button(
|
81 |
f"View model on 🤗",
|
82 |
on_click=lambda hit=hit: webbrowser.open(f"https://huggingface.co/{hit['modelId']}"),
|
requirements.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
git+https://github.com/NouamaneTazi/hf_search
|
2 |
pandas
|
3 |
streamlit
|
4 |
huggingface_hub
|
5 |
numerize
|
|
|
|
|
|
1 |
pandas
|
2 |
streamlit
|
3 |
huggingface_hub
|
4 |
numerize
|
5 |
+
git+https://github.com/NouamaneTazi/hf_search
|
st_utils.py
CHANGED
@@ -68,8 +68,8 @@ def bm25_search(query, limit=5, filters={}):
|
|
68 |
{
|
69 |
"modelId": hit["modelId"],
|
70 |
"tags": hit["tags"],
|
71 |
-
"downloads":
|
72 |
-
"likes":
|
73 |
"readme": hit.get("readme", None),
|
74 |
}
|
75 |
for hit in hits
|
|
|
68 |
{
|
69 |
"modelId": hit["modelId"],
|
70 |
"tags": hit["tags"],
|
71 |
+
"downloads": hit["downloads"],
|
72 |
+
"likes": hit["likes"],
|
73 |
"readme": hit.get("readme", None),
|
74 |
}
|
75 |
for hit in hits
|