spacr.qt.widgets.model_share_dialog

The form that collects a shared model’s scorecard before it is uploaded.

Also the consent step and the upload shared by every community training-data contribution, so each screen that contributes asks the same question once and sends the same way, and Make Masks’ dialog for sending images with their masks to a community dataset the user names.

Classes

ConsentDialog

Asked once, before the first contribution leaves the machine.

ContributeMasksDialog

Send images and their masks to a community dataset the user names.

ShareDialog

One line per scorecard column, in the order the card prints them.

Functions

ask_community_consent(→ bool)

Ask once, before the first community contribution; remember a yes.

community_consented(→ bool)

Whether the contributor already agreed to the community licence.

contribute_masks_tooltip(→ str)

What "Contribute images and masks…" does: its tooltip and the dialog's intro.

upload_with_own_login(→ str)

Send a contribution, with the contributor's own Hugging Face login if any.

Module Contents

class spacr.qt.widgets.model_share_dialog.ConsentDialog(parent: PySide6.QtWidgets.QWidget | None = None)[source]

Bases: PySide6.QtWidgets.QDialog

Asked once, before the first contribution leaves the machine.

Parameters:

parent – the owning widget.

Build the two statements and the buttons.

Parameters:

parent – the owning widget.

class spacr.qt.widgets.model_share_dialog.ContributeMasksDialog(*, current: Dict[str, Any] | None = None, curated: List[Dict[str, Any]] | None = None, images_dir: str = '', masks_dir: str = '', name: str = '', upload: Callable[[Any, str], str] | None = None, threaded: bool = True, parent: PySide6.QtWidgets.QWidget | None = None)[source]

Bases: PySide6.QtWidgets.QDialog

Send images and their masks to a community dataset the user names.

Make Masks’ way into the community training datasets. Three sources, whichever are on offer: the image on screen with the mask being edited, every image of the open folder with a saved mask, or an images folder and a masks folder matched by file name. The user names the dataset (organism, object type, stain), which becomes einarolafsson/community_<name>, and may add notes. Nothing is sent without a mask for every image, the consent asked once for every community contribution, and the conscience text beside Upload.

Parameters:
  • current – the image on screen as one {name, source, labels} item, or None when no image is open.

  • curated – the open folder’s images with saved masks, as {name, source, mask} items (mask a file read at upload) or {name, source, labels}; None when no folder is open.

  • images_dir – the images folder to start with.

  • masks_dir – the masks folder to start with.

  • name – the dataset name to start with; the last one used when empty.

  • upload – fn(folder, target) -> url in place of upload_with_own_login() (tests).

  • threaded – send on a worker thread; False sends inline (tests).

  • parent – the owning widget.

Build the sources, the two folder fields, the name and the notes.

Parameters:
  • current – see the class docstring.

  • curated – see the class docstring.

  • images_dir – see the class docstring.

  • masks_dir – see the class docstring.

  • name – see the class docstring.

  • upload – see the class docstring.

  • threaded – see the class docstring.

  • parent – see the class docstring.

source() → str[source]

The source chosen: "current", "curated" or "folders".

target() → str[source]

The community target the typed name maps to, or "".

upload(*_args: Any) → bool[source]

Check, ask for consent once, write the contribution and send it.

Returns:

True when an upload was started.

use(source: str) → None[source]

Switch to one of the sources on offer.

Parameters:

source – "current", "curated" or "folders".

class spacr.qt.widgets.model_share_dialog.ShareDialog(filename: str, parent: PySide6.QtWidgets.QWidget | None = None)[source]

Bases: PySide6.QtWidgets.QDialog

One line per scorecard column, in the order the card prints them.

Blank is allowed everywhere: a card that says “not recorded” is honest, and a form that refused to submit without a number would be answered with a made-up one.

Build the form for sharing filename.

Parameters:
  • filename – the checkpoint being shared, named in the title.

  • parent – the dialog’s parent widget.

train_data_dir() → str[source]

The chosen training-data folder, or an empty string.

values() → Dict[str, str][source]

What the user typed, by field key.

Ask once, before the first community contribution; remember a yes.

Parameters:
  • parent – the window the question belongs to.

  • ask – fn() -> bool in place of ConsentDialog (tests).

Returns:

True when the contributor has agreed, now or before.

spacr.qt.widgets.model_share_dialog.community_consented() → bool[source]

Whether the contributor already agreed to the community licence.

spacr.qt.widgets.model_share_dialog.contribute_masks_tooltip() → str[source]

What “Contribute images and masks…” does: its tooltip and the dialog’s intro.

spacr.qt.widgets.model_share_dialog.upload_with_own_login(folder: Any, target: str) → str[source]

Send a contribution, with the contributor’s own Hugging Face login if any.

With a login, the pull request is opened with it (see contribute()). Without one, the folder goes through spaCR’s upload Space, which opens the same pull request with its own token, so no account is needed.

Parameters:
Returns:

the pull request’s URL.

Raises:

RuntimeError – with no login, when the upload Space cannot take it; the message says why and how to send it with a login instead.