-
Notifications
You must be signed in to change notification settings - Fork 3
/
repository.py
66 lines (53 loc) · 1.26 KB
/
repository.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
from threading import Thread
# hugging face
from huggingface_hub import upload_folder
def create_output_dir(output_dir):
if output_dir is not None:
os.makedirs(output_dir, exist_ok=True)
def save_to_local_directory(
output_dir,
unet,
unet_params,
):
print("saving trained weights...")
unet.save_pretrained(
save_directory=output_dir,
params=unet_params,
)
print("trained weights saved...")
def save_to_repository(
output_dir,
unet,
unet_params,
repo_id,
):
print("saving trained weights...")
unet.save_pretrained(
save_directory=output_dir,
params=unet_params,
)
print("trained weights saved...")
Thread(
target=lambda: upload_to_repository(
repo_id,
output_dir,
"End of training epoch.",
)
).start()
def upload_to_repository(
output_dir,
repo_id,
commit_message,
):
upload_folder(
repo_id=repo_id,
folder_path=output_dir,
commit_message=commit_message,
)
if __name__ == "__main__":
upload_to_repository(
"/data/output.bak/000920",
"character-aware-diffusion/charred",
"Latest training epoch version as of Apr 28 11:03PM UST.",
)