Create publish.py
Browse files- publish.py +23 -0
publish.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from huggingface_hub import HfApi
|
2 |
+
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
|
3 |
+
|
4 |
+
# Define your Hugging Face API token and repo ID
|
5 |
+
hf_token = "your_huggingface_token"
|
6 |
+
repo_id = "your_username/trocr-finetuned-funsd"
|
7 |
+
|
8 |
+
# Initialize HfApi
|
9 |
+
api = HfApi()
|
10 |
+
api.login(hf_token)
|
11 |
+
|
12 |
+
# Define the folder path
|
13 |
+
folder_path = "./trocr-finetuned-funsd"
|
14 |
+
|
15 |
+
# Upload the model
|
16 |
+
api.upload_folder(
|
17 |
+
folder_path=folder_path,
|
18 |
+
repo_id=repo_id,
|
19 |
+
repo_type="model",
|
20 |
+
path_in_repo=".",
|
21 |
+
)
|
22 |
+
|
23 |
+
print(f"Model uploaded to {repo_id}")
|