m-ric HF staff commited on
Commit
a307a17
·
verified ·
1 Parent(s): b406dc3

Upload tool

Browse files
Files changed (4) hide show
  1. app.py +4 -0
  2. model_downloads.py +21 -0
  3. requirements.txt +2 -0
  4. tool_config.json +5 -0
app.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ from transformers import launch_gradio_demo
2
+ from model_downloads import HFModelDownloadsTool
3
+
4
+ launch_gradio_demo(HFModelDownloadsTool)
model_downloads.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import Tool
2
+ from huggingface_hub import list_models
3
+
4
+ class HFModelDownloadsTool(Tool):
5
+ name = "model_download_counter"
6
+ description = (
7
+ "This is a tool that returns the most downloaded model of a given task on the Hugging Face Hub. "
8
+ "It returns the name of the checkpoint."
9
+ )
10
+
11
+ inputs = {
12
+ "name": {
13
+ "type": str,
14
+ "description": "the name of the category (such as text-classification, depth-estimation, etc)",
15
+ }
16
+ }
17
+ output_type = str
18
+
19
+ def __call__(self, task: str):
20
+ model = next(iter(list_models(filter=task, sort="downloads", direction=-1)))
21
+ return model.id
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ huggingface_hub
2
+ transformers
tool_config.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "description": "This is a tool that returns the most downloaded model of a given task on the Hugging Face Hub. It returns the name of the checkpoint.",
3
+ "name": "model_download_counter",
4
+ "tool_class": "model_downloads.HFModelDownloadsTool"
5
+ }