Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -43,21 +43,38 @@ def get_model_config(hf_model: str) -> dict[str, Any]:
|
|
43 |
f"https://huggingface.co/{hf_model}"
|
44 |
).text
|
45 |
param_props_idx = model_page.find('data-target="ModelSafetensorsParams"')
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
# assume fp16 weights
|
63 |
config["parameters"] = model_size / 2
|
|
|
43 |
f"https://huggingface.co/{hf_model}"
|
44 |
).text
|
45 |
param_props_idx = model_page.find('data-target="ModelSafetensorsParams"')
|
46 |
+
if param_props_idx != -1:
|
47 |
+
param_props_start = model_page.rfind("<div", 0, param_props_idx)
|
48 |
+
model_size = (
|
49 |
+
json.loads(
|
50 |
+
[
|
51 |
+
prop
|
52 |
+
for prop in model_page[param_props_start:param_props_idx].split(" ")
|
53 |
+
if prop.startswith("data-props=")
|
54 |
+
][0]
|
55 |
+
.split("=")[1]
|
56 |
+
.replace('"', "")
|
57 |
+
.replace(""", '"')
|
58 |
+
)["safetensors"]["total"]
|
59 |
+
* 2
|
60 |
+
)
|
61 |
+
else:
|
62 |
+
param_props_idx = model_page.find('data-target="ModelHeader"')
|
63 |
+
param_props_start = model_page.rfind("<div", 0, param_props_idx)
|
64 |
+
model_size = (
|
65 |
+
json.loads(
|
66 |
+
[
|
67 |
+
prop
|
68 |
+
for prop in model_page[param_props_start:param_props_idx].split(" ")
|
69 |
+
if prop.startswith("data-props=")
|
70 |
+
][0]
|
71 |
+
.split("=")[1]
|
72 |
+
.replace('"', "")
|
73 |
+
.replace(""", '"')
|
74 |
+
)["model"]["safetensors"]["total"]
|
75 |
+
* 2
|
76 |
+
)
|
77 |
+
|
78 |
|
79 |
# assume fp16 weights
|
80 |
config["parameters"] = model_size / 2
|