alif-munim commited on
Commit
f131300
·
verified ·
1 Parent(s): 17b561f

Upload tool

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