surfansun commited on
Commit
dd191dc
1 Parent(s): 07687b6

Upload tool

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