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¶
Asked once, before the first contribution leaves the machine. |
|
Send images and their masks to a community dataset the user names. |
|
One line per scorecard column, in the order the card prints them. |
Functions¶
|
Ask once, before the first community contribution; remember a yes. |
|
Whether the contributor already agreed to the community licence. |
|
What "Contribute images and masks…" does: its tooltip and the dialog's intro. |
|
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.QDialogAsked 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.QDialogSend 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 (maska 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) -> urlin place ofupload_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.
- class spacr.qt.widgets.model_share_dialog.ShareDialog(filename: str, parent: PySide6.QtWidgets.QWidget | None = None)[source]¶
Bases:
PySide6.QtWidgets.QDialogOne 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.
- spacr.qt.widgets.model_share_dialog.ask_community_consent(parent: PySide6.QtWidgets.QWidget | None = None, *, ask: Callable[[], bool] | None = None) → bool[source]¶
Ask once, before the first community contribution; remember a yes.
- Parameters:
parent – the window the question belongs to.
ask –
fn() -> boolin place ofConsentDialog(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:
folder – a folder
write_contribution()made.target – the community collection; see
community_repo().
- 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.