Spaces:
Runtime error
Runtime error
Upload tool
Browse files- app.py +3 -0
- model_downloads.py +14 -0
- requirements.txt +2 -0
- tool_config.json +7 -0
app.py
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
from transformers.tools.base import launch_gradio_demo from __main__ import HFModelDownloadsTool
|
2 |
+
|
3 |
+
launch_gradio_demo(HFModelDownloadsTool)
|
model_downloads.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers.tools import Tool
|
2 |
+
from huggingface_hub import list_models
|
3 |
+
|
4 |
+
|
5 |
+
class HFModelDownloadsTool(Tool):
|
6 |
+
description = (
|
7 |
+
"This is a tool that returns the most downloaded model of a given task on the Hugging Face Hub. "
|
8 |
+
"It takes the name of the category (such as text-classification, depth-estimation, etc), and "
|
9 |
+
"returns the name of the checkpoint alongside its 30-day download numbers."
|
10 |
+
)
|
11 |
+
|
12 |
+
def __call__(self, task: str):
|
13 |
+
model = next(iter(list_models(filter=task, sort='downloads', direction=-1)))
|
14 |
+
return f"{model.id} with {model.downloads} downloads over the past 30 days."
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
huggingface_hub
|
2 |
+
transformers
|
tool_config.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"h_f_model_downloads": {
|
3 |
+
"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 alongside its 30-day download numbers.",
|
4 |
+
"name": "",
|
5 |
+
"tool_class": "__main__.HFModelDownloadsTool"
|
6 |
+
}
|
7 |
+
}
|