Spaces:
Running
Running
Commit
•
73856e8
1
Parent(s):
3e2638f
Add token to download
Browse files- convert.py +3 -3
convert.py
CHANGED
@@ -20,12 +20,12 @@ from transformers import CONFIG_MAPPING
|
|
20 |
COMMIT_MESSAGE = " This PR adds fp32 and fp16 weights in PyTorch and safetensors format to {}"
|
21 |
|
22 |
|
23 |
-
def convert_single(model_id: str, filename: str, model_type: str, sample_size: int, scheduler_type: str, extract_ema: bool, folder: str, progress):
|
24 |
from_safetensors = filename.endswith(".safetensors")
|
25 |
|
26 |
progress(0, desc="Downloading model")
|
27 |
local_file = os.path.join(model_id, filename)
|
28 |
-
ckpt_file = local_file if os.path.isfile(local_file) else hf_hub_download(repo_id=model_id, filename=filename)
|
29 |
|
30 |
if model_type == "v1":
|
31 |
config_url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml"
|
@@ -81,7 +81,7 @@ def convert(token: str, model_id: str, filename: str, model_type: str, sample_si
|
|
81 |
os.makedirs(folder)
|
82 |
new_pr = None
|
83 |
try:
|
84 |
-
folder = convert_single(model_id, filename, model_type, sample_size, scheduler_type, extract_ema, folder, progress)
|
85 |
progress(0.7, desc="Uploading to Hub")
|
86 |
new_pr = api.upload_folder(folder_path=folder, path_in_repo="./", repo_id=model_id, repo_type="model", token=token, commit_message=pr_title, commit_description=COMMIT_MESSAGE.format(model_id), create_pr=True)
|
87 |
pr_number = new_pr.split("%2F")[-1].split("/")[0]
|
|
|
20 |
COMMIT_MESSAGE = " This PR adds fp32 and fp16 weights in PyTorch and safetensors format to {}"
|
21 |
|
22 |
|
23 |
+
def convert_single(model_id: str, token:str, filename: str, model_type: str, sample_size: int, scheduler_type: str, extract_ema: bool, folder: str, progress):
|
24 |
from_safetensors = filename.endswith(".safetensors")
|
25 |
|
26 |
progress(0, desc="Downloading model")
|
27 |
local_file = os.path.join(model_id, filename)
|
28 |
+
ckpt_file = local_file if os.path.isfile(local_file) else hf_hub_download(repo_id=model_id, filename=filename, token=token)
|
29 |
|
30 |
if model_type == "v1":
|
31 |
config_url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml"
|
|
|
81 |
os.makedirs(folder)
|
82 |
new_pr = None
|
83 |
try:
|
84 |
+
folder = convert_single(model_id, token, filename, model_type, sample_size, scheduler_type, extract_ema, folder, progress)
|
85 |
progress(0.7, desc="Uploading to Hub")
|
86 |
new_pr = api.upload_folder(folder_path=folder, path_in_repo="./", repo_id=model_id, repo_type="model", token=token, commit_message=pr_title, commit_description=COMMIT_MESSAGE.format(model_id), create_pr=True)
|
87 |
pr_number = new_pr.split("%2F")[-1].split("/")[0]
|