updating space to have autocomlete
Browse files- app.py +20 -6
- requirements.txt +3 -1
app.py
CHANGED
@@ -5,6 +5,7 @@ from huggingface_hub import HfApi
|
|
5 |
from huggingface_hub.errors import RepositoryNotFoundError
|
6 |
import pandas as pd
|
7 |
import plotly.express as px
|
|
|
8 |
|
9 |
HF_API = HfApi()
|
10 |
|
@@ -67,6 +68,7 @@ def get_repo_info(r_type, r_id):
|
|
67 |
gr.Row(visible=False),
|
68 |
gr.Dataframe(visible=False),
|
69 |
gr.Plot(visible=False),
|
|
|
70 |
gr.Dataframe(visible=False),
|
71 |
)
|
72 |
rf_sizes_df = (
|
@@ -77,6 +79,7 @@ def get_repo_info(r_type, r_id):
|
|
77 |
# check if repo_sizes is just {}
|
78 |
if not repo_sizes:
|
79 |
r_sizes_component = gr.Dataframe(visible=False)
|
|
|
80 |
else:
|
81 |
r_sizes_df = pd.DataFrame(repo_sizes, index=["size"]).T.reset_index(
|
82 |
names="branch"
|
@@ -86,6 +89,7 @@ def get_repo_info(r_type, r_id):
|
|
86 |
r_sizes_component = gr.Dataframe(
|
87 |
value=r_sizes_df[["Branch", "Size"]], visible=True
|
88 |
)
|
|
|
89 |
|
90 |
rf_sizes_df["formatted_size"] = rf_sizes_df["size"].apply(format_repo_size)
|
91 |
rf_sizes_df.columns = ["Extension", "bytes", "Count", "Size"]
|
@@ -104,17 +108,25 @@ def get_repo_info(r_type, r_id):
|
|
104 |
visible=True,
|
105 |
),
|
106 |
gr.Plot(rf_sizes_plot, visible=True),
|
|
|
107 |
r_sizes_component,
|
108 |
)
|
109 |
|
110 |
|
111 |
-
with gr.Blocks(theme="
|
112 |
gr.Markdown("# Repository Information")
|
113 |
gr.Markdown(
|
114 |
"Enter a repository ID and repository type and get back information about the repository's files and branches."
|
115 |
)
|
116 |
with gr.Blocks():
|
117 |
-
repo_id = gr.Textbox(label="Repository ID", placeholder="123456")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
repo_type = gr.Radio(
|
119 |
choices=["model", "dataset", "space"],
|
120 |
label="Repository Type",
|
@@ -122,19 +134,21 @@ with gr.Blocks(theme="citrus") as demo:
|
|
122 |
)
|
123 |
search_button = gr.Button(value="Search")
|
124 |
with gr.Blocks():
|
125 |
-
with gr.Row(visible=False) as
|
126 |
with gr.Column():
|
127 |
gr.Markdown("## File Information")
|
128 |
with gr.Row():
|
129 |
file_info = gr.Dataframe(visible=False)
|
130 |
file_info_plot = gr.Plot(visible=False)
|
131 |
-
gr.
|
132 |
-
|
|
|
|
|
133 |
|
134 |
search_button.click(
|
135 |
get_repo_info,
|
136 |
inputs=[repo_type, repo_id],
|
137 |
-
outputs=[
|
138 |
)
|
139 |
|
140 |
demo.launch()
|
|
|
5 |
from huggingface_hub.errors import RepositoryNotFoundError
|
6 |
import pandas as pd
|
7 |
import plotly.express as px
|
8 |
+
from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
9 |
|
10 |
HF_API = HfApi()
|
11 |
|
|
|
68 |
gr.Row(visible=False),
|
69 |
gr.Dataframe(visible=False),
|
70 |
gr.Plot(visible=False),
|
71 |
+
gr.Row(visible=False),
|
72 |
gr.Dataframe(visible=False),
|
73 |
)
|
74 |
rf_sizes_df = (
|
|
|
79 |
# check if repo_sizes is just {}
|
80 |
if not repo_sizes:
|
81 |
r_sizes_component = gr.Dataframe(visible=False)
|
82 |
+
b_block = gr.Row(visible=False)
|
83 |
else:
|
84 |
r_sizes_df = pd.DataFrame(repo_sizes, index=["size"]).T.reset_index(
|
85 |
names="branch"
|
|
|
89 |
r_sizes_component = gr.Dataframe(
|
90 |
value=r_sizes_df[["Branch", "Size"]], visible=True
|
91 |
)
|
92 |
+
b_block = gr.Row(visible=True)
|
93 |
|
94 |
rf_sizes_df["formatted_size"] = rf_sizes_df["size"].apply(format_repo_size)
|
95 |
rf_sizes_df.columns = ["Extension", "bytes", "Count", "Size"]
|
|
|
108 |
visible=True,
|
109 |
),
|
110 |
gr.Plot(rf_sizes_plot, visible=True),
|
111 |
+
b_block,
|
112 |
r_sizes_component,
|
113 |
)
|
114 |
|
115 |
|
116 |
+
with gr.Blocks(theme="ocean") as demo:
|
117 |
gr.Markdown("# Repository Information")
|
118 |
gr.Markdown(
|
119 |
"Enter a repository ID and repository type and get back information about the repository's files and branches."
|
120 |
)
|
121 |
with gr.Blocks():
|
122 |
+
# repo_id = gr.Textbox(label="Repository ID", placeholder="123456")
|
123 |
+
|
124 |
+
repo_id = HuggingfaceHubSearch(
|
125 |
+
label="Hub Model ID",
|
126 |
+
placeholder="Search for model id on Huggingface",
|
127 |
+
search_type=["model", "dataset"],
|
128 |
+
)
|
129 |
+
|
130 |
repo_type = gr.Radio(
|
131 |
choices=["model", "dataset", "space"],
|
132 |
label="Repository Type",
|
|
|
134 |
)
|
135 |
search_button = gr.Button(value="Search")
|
136 |
with gr.Blocks():
|
137 |
+
with gr.Row(visible=False) as results_block:
|
138 |
with gr.Column():
|
139 |
gr.Markdown("## File Information")
|
140 |
with gr.Row():
|
141 |
file_info = gr.Dataframe(visible=False)
|
142 |
file_info_plot = gr.Plot(visible=False)
|
143 |
+
with gr.Row(visible=False) as branch_block:
|
144 |
+
with gr.Column():
|
145 |
+
gr.Markdown("## Branch Sizes")
|
146 |
+
branch_sizes = gr.Dataframe(visible=False)
|
147 |
|
148 |
search_button.click(
|
149 |
get_repo_info,
|
150 |
inputs=[repo_type, repo_id],
|
151 |
+
outputs=[results_block, file_info, file_info_plot, branch_block, branch_sizes],
|
152 |
)
|
153 |
|
154 |
demo.launch()
|
requirements.txt
CHANGED
@@ -1,10 +1,11 @@
|
|
1 |
aiofiles==23.2.1
|
2 |
annotated-types==0.7.0
|
3 |
anyio==4.6.2.post1
|
|
|
4 |
certifi==2024.8.30
|
5 |
charset-normalizer==3.4.0
|
6 |
click==8.1.7
|
7 |
-
colorama==0.4.6
|
8 |
fastapi==0.115.5
|
9 |
ffmpy==0.4.0
|
10 |
filelock==3.16.1
|
@@ -52,3 +53,4 @@ tzdata==2024.2
|
|
52 |
urllib3==2.2.3
|
53 |
uvicorn==0.32.0
|
54 |
websockets==12.0
|
|
|
|
1 |
aiofiles==23.2.1
|
2 |
annotated-types==0.7.0
|
3 |
anyio==4.6.2.post1
|
4 |
+
audioop-lts==0.2.1
|
5 |
certifi==2024.8.30
|
6 |
charset-normalizer==3.4.0
|
7 |
click==8.1.7
|
8 |
+
colorama==0.4.6
|
9 |
fastapi==0.115.5
|
10 |
ffmpy==0.4.0
|
11 |
filelock==3.16.1
|
|
|
53 |
urllib3==2.2.3
|
54 |
uvicorn==0.32.0
|
55 |
websockets==12.0
|
56 |
+
gradio_huggingfacehub_search==0.0.7
|