NyxKrage commited on
Commit
b38ea7a
1 Parent(s): 4c8f20d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -15
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
- param_props_start = model_page.rfind("<div", 0, param_props_idx)
47
- model_size = (
48
- json.loads(
49
- [
50
- prop
51
- for prop in model_page[param_props_start:param_props_idx].split(" ")
52
- if prop.startswith("data-props=")
53
- ][0]
54
- .split("=")[1]
55
- .replace('"', "")
56
- .replace("&quot;", '"')
57
- )["safetensors"]["total"]
58
- * 2
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("&quot;", '"')
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("&quot;", '"')
74
+ )["model"]["safetensors"]["total"]
75
+ * 2
76
+ )
77
+
78
 
79
  # assume fp16 weights
80
  config["parameters"] = model_size / 2