spacr.model_cards¶
The 3-page model cards of the Model Zoo: data, repository mapping, images.
Each published segmentation model has three card pages on Hugging Face
(cards/page1.png to page3.png): its scores against the stock base, its
training facts, and an about-and-links page. The same data ships with spaCR as
resources/model_cards/<repo>.json, so a card can be shown as text when the
images cannot be fetched.
Nothing here imports Qt; the viewer lives in
spacr.qt.widgets.model_card_viewer.
Functions¶
|
Page 3 as plain sentences, without the empty fields. |
|
Where the page images of |
|
The cached image of each page, |
|
The card data of a |
|
The zoo keys that have a 3-page card. |
|
Remove the cached images of |
|
Page 2 as |
|
Download the missing page images of |
|
The Hugging Face URL of the model the card describes. |
|
The text fallback of one card page (1-based) as a small HTML body. |
|
The Hugging Face URL of card page |
|
The |
|
The Hugging Face page of a model repository. |
|
Page 1 as |
Module Contents¶
- spacr.model_cards.about_lines(card: Dict[str, Any]) List[str][source]¶
Page 3 as plain sentences, without the empty fields.
- Parameters:
card – the card data.
- spacr.model_cards.cache_dir(repo: str) pathlib.Path[source]¶
Where the page images of
repoare cached, under the spaCR home.- Parameters:
repo –
owner/repo.
- spacr.model_cards.cached_pages(repo: str) List[pathlib.Path | None][source]¶
The cached image of each page,
Nonewhere it is not cached.- Parameters:
repo –
owner/repo.
- spacr.model_cards.card_for_entry(entry: Any) Dict[str, Any] | None[source]¶
The card data of a
ModelEntry, orNone.Matched on the zoo key, then on the repository the entry is fetched from.
- Parameters:
entry – the model zoo entry.
- spacr.model_cards.clear_cache(repo: str) None[source]¶
Remove the cached images of
repo.- Parameters:
repo –
owner/repo.
- spacr.model_cards.fact_rows(card: Dict[str, Any]) List[Tuple[str, str]][source]¶
Page 2 as
(fact, value)pairs.- Parameters:
card – the card data.
- spacr.model_cards.fetch_pages(repo: str, fetch: Callable[[str], bytes] | None = None) List[pathlib.Path][source]¶
Download the missing page images of
repointo the cache.- Parameters:
repo –
owner/repo.fetch – byte source taking a URL; defaults to
urlopen.
- Returns:
the three cached paths.
- Raises:
OSError – when a page cannot be fetched or is not a PNG. Pages fetched before the failure stay cached.
- spacr.model_cards.model_link(card: Dict[str, Any]) str[source]¶
The Hugging Face URL of the model the card describes.
- Parameters:
card – the card data.
- spacr.model_cards.page_html(card: Dict[str, Any], page: int, headers: Tuple[str, str, str, str] = ('Score', 'Value', 'Fact', 'Value')) str[source]¶
The text fallback of one card page (1-based) as a small HTML body.
- Parameters:
card – the card data.
page – the page number, from 1.
headers – the already translated column headings for the scores and facts tables.
- spacr.model_cards.page_url(repo: str, page: int) str[source]¶
The Hugging Face URL of card page
page(1-based) ofrepo.- Parameters:
repo –
owner/repo.page – the page number, from 1.
- spacr.model_cards.repo_of_key(key: Any) str[source]¶
The
owner/repoof a zoo key that has a card, else''.- Parameters:
key – a model zoo key.