faaany commited on
Commit
eac8247
1 Parent(s): 3be6bb5

Upload tool

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