Spaces:
Running
Running
Update convert.py
Browse files- convert.py +4 -2
convert.py
CHANGED
@@ -71,7 +71,7 @@ def convert_multi(model_id: str, folder: str) -> List["CommitOperationAdd"]:
|
|
71 |
newdata = {k: v for k, v in data.items()}
|
72 |
newmap = {k: rename(v) for k, v in data["weight_map"].items()}
|
73 |
newdata["weight_map"] = newmap
|
74 |
-
json.dump(newdata, f)
|
75 |
local_filenames.append(index)
|
76 |
|
77 |
operations = [
|
@@ -227,13 +227,15 @@ def convert(api: "HfApi", model_id: str, force: bool = False) -> Optional["Commi
|
|
227 |
try:
|
228 |
operations = None
|
229 |
pr = previous_pr(api, model_id, pr_title)
|
|
|
|
|
230 |
if any(filename.endswith(".safetensors") for filename in filenames) and not force:
|
231 |
raise AlreadyExists(f"Model {model_id} is already converted, skipping..")
|
232 |
elif pr is not None and not force:
|
233 |
url = f"https://huggingface.co/{model_id}/discussions/{pr.num}"
|
234 |
new_pr = pr
|
235 |
raise AlreadyExists(f"Model {model_id} already has an open PR check out {url}")
|
236 |
-
elif
|
237 |
if "pytorch_model.bin" in filenames:
|
238 |
operations = convert_single(model_id, folder)
|
239 |
elif "pytorch_model.bin.index.json" in filenames:
|
|
|
71 |
newdata = {k: v for k, v in data.items()}
|
72 |
newmap = {k: rename(v) for k, v in data["weight_map"].items()}
|
73 |
newdata["weight_map"] = newmap
|
74 |
+
json.dump(newdata, f, indent=4)
|
75 |
local_filenames.append(index)
|
76 |
|
77 |
operations = [
|
|
|
227 |
try:
|
228 |
operations = None
|
229 |
pr = previous_pr(api, model_id, pr_title)
|
230 |
+
|
231 |
+
library_name = getattr(info, "library_name", None)
|
232 |
if any(filename.endswith(".safetensors") for filename in filenames) and not force:
|
233 |
raise AlreadyExists(f"Model {model_id} is already converted, skipping..")
|
234 |
elif pr is not None and not force:
|
235 |
url = f"https://huggingface.co/{model_id}/discussions/{pr.num}"
|
236 |
new_pr = pr
|
237 |
raise AlreadyExists(f"Model {model_id} already has an open PR check out {url}")
|
238 |
+
elif library_name == "transformers":
|
239 |
if "pytorch_model.bin" in filenames:
|
240 |
operations = convert_single(model_id, folder)
|
241 |
elif "pytorch_model.bin.index.json" in filenames:
|