Benjamin Bossan commited on
Commit
e83e18b
1 Parent(s): ec0feb6

Fix bug with parsing img when val is no string

Browse files
Files changed (1) hide show
  1. utils.py +8 -7
utils.py CHANGED
@@ -94,7 +94,7 @@ def iterate_key_section_content(
94
  data: dict[str, Section],
95
  parent_section: str = "",
96
  parent_keys: list[str] | None = None,
97
- level=0,
98
  ) -> SectionInfo:
99
  parent_keys = parent_keys or []
100
 
@@ -111,12 +111,13 @@ def iterate_key_section_content(
111
  content = val.content
112
 
113
  is_fig = getattr(val, "is_fig", False)
114
- img_match = PAT_MD_IMG.match(val.content)
115
- if img_match: # image section found in parsed model card
116
- is_fig = True
117
- img_title = img_match.groupdict()["image_title"]
118
- img_path = img_match.groupdict()["image_path"]
119
- content = PlotSection(alt_text=img_title, path=img_path)
 
120
 
121
  yield SectionInfo(
122
  return_key=return_key,
 
94
  data: dict[str, Section],
95
  parent_section: str = "",
96
  parent_keys: list[str] | None = None,
97
+ level: int = 0,
98
  ) -> SectionInfo:
99
  parent_keys = parent_keys or []
100
 
 
111
  content = val.content
112
 
113
  is_fig = getattr(val, "is_fig", False)
114
+ if isinstance(val.content, str):
115
+ img_match = PAT_MD_IMG.match(val.content)
116
+ if img_match: # image section found in parsed model card
117
+ is_fig = True
118
+ img_title = img_match.groupdict()["image_title"]
119
+ img_path = img_match.groupdict()["image_path"]
120
+ content = PlotSection(alt_text=img_title, path=img_path)
121
 
122
  yield SectionInfo(
123
  return_key=return_key,