Spaces:
Runtime error
Runtime error
patrickvonplaten
commited on
Commit
•
a59fb21
1
Parent(s):
e291ad0
Upload tool
Browse files- app.py +4 -0
- model_downloads.py +17 -0
- requirements.txt +2 -0
- tool_config.json +5 -0
app.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers.tools.base import launch_gradio_demo
|
2 |
+
from model_downloads import HFModelDownloadsTool
|
3 |
+
|
4 |
+
launch_gradio_demo(HFModelDownloadsTool)
|
model_downloads.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)))
|
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 |
+
}
|