mjschock commited on
Commit
ff6a139
1 Parent(s): 6e9bde8

Upload tool

Browse files
Files changed (4) hide show
  1. app.py +4 -0
  2. model_downloads.py +18 -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,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
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 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
+ }