Skip to content

Widgets

button

tsx
function button(text?: string): Button;

A generic GUI button component.

Parameters

OptionTypeDescriptionRequired
textstringThe text of the button

Streams

NameTypeDescriptionHold
$textstringStream defining the button text
$type'default' | 'success' | 'warning' | 'danger'Stream defining the button type
$clickundefinedStream of click events
$pressedbooleanStream of binary events indicating if the button is pressed
$loadingbooleanStream of binary events indicating if the button is in loading mode
$loadingbooleanStream of binary events indicating if the button is in loading mode
$disabledbooleanStream defining if the input is disabled.

Screenshot

Screenshot of the button component

Example

js
const capture = button('Hold to record instances');
capture.title = 'Capture instances to the training set';

capture.$click.subscribe((x) => console.log('button $click:', x));
capture.$pressed.subscribe((x) => console.log('button $pressed:', x));

fileUpload

tsx
function fileUpload(): FileUpload;

A file upload component, that creates a stream of files.

Streams

NameTypeDescriptionHold
$filesStream<never()>Stream of files

Example

js
const myFileUpload = marcelle.fileUpload();
myFileUpload.$files.subscribe((x) => console.log('fileUpload $files:', x));

imageUpload

tsx
function imageUpload({ width?: number, height?: number }): ImageUpload;

An Image upload component, that creates a stream of images and thumbnails. Images are cropped and rescaled to match the target dimensions, if these are non-zero, otherwise the dimensions are unchanged.

Parameters

OptionTypeDescriptionRequiredDefault
widthnumberTarget image width0
heightnumberTarget image height0

Streams

NameTypeDescriptionHold
$imagesStream<ImageData>Stream of images in the ImageData format.
$thumbnailsStream<string>Stream of thumbnail images in base64 dataURI format.

Screenshot

Screenshot of the imageUpload component

Example

js
const imgUpload = marcelle.imageUpload();
imgUpload.$images.subscribe((x) => console.log('imageUpload $images:', x));

modelParameters

tsx
function modelParameters(p: Parametrable): ModelParameters;

This component provides an GUI for visualizing and adjusting parameters. It takes a Parametrable object as argument, which is an object (typically a model) carrying a parameters property which is a record of parameter streams:

ts
interface Parametrable {
  parameters: {
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    [name: string]: Stream<any>;
  };
}

The component will automatically display all parameters with appropriate GUI Widgets.

Parameters

OptionTypeDescriptionRequired
pParametrableAn object exposing parameters as streams to visualize and make editable

Screenshot

Screenshot of the parameters component

Examples

js
const classifier = marcelle.mlp({ layers: [64, 32], epochs: 20 });
const params = marcelle.parameters(classifier);

dashboard.page('Training').use(params);
js
const parametrable = {
  parameters: {
    int: new Stream(12, true),
    float: new Stream(-0.0000045, true),
    intArray: new Stream(Array.from(Array(3), () => Math.floor(100 * Math.random()))),
    floatArray: new Stream(Array.from(Array(3), () => Math.random())),
    string: new Stream('test'),
    menu: new Stream('three'),
    bool: new Stream(false),
  },
};

const p = modelParameters(parametrable, {
  menu: { type: 'menu', options: ['one', 'two', 'three'] },
});

number

tsx
function number(defaultValue?: number): Number;

A generic GUI number input component.

Parameters

OptionTypeDescriptionrequired
defaultValuenumberInitial value. Defaults to 0.

Streams

NameTypeDescriptionHold
$valuenumberStream defining the input's value
$disabledbooleanStream defining if the input is disabled.

Screenshot

Screenshot of the number component

Example

js
const epochs = number(30);
epochs.title = 'Number of Epochs';

epochs.$value.subscribe(console.log);

numberArray

tsx
function numberArray(defaultValue?: number[]): NumberArray;

A generic GUI number array input component.

Parameters

OptionTypeDescriptionrequired
defaultValuenumber[]Initial value. Defaults to [].

Streams

NameTypeDescriptionHold
$valuenumber[]Stream defining the input's value
$disabledbooleanStream defining if the input is disabled.

Screenshot

Screenshot of the number-array component

Example

js
const neuronsPerLayer = numberArray([64, 32, 16]);
neuronsPerLayer.title = 'Number of Neurons per Layer';

neuronsPerLayer.$value.subscribe(console.log);

select

tsx
function select(options: string[], value?: string): Select;

A generic GUI Select component.

Parameters

OptionTypeDescriptionRequired
optionsstring[]The select menu options
valuestringThe default value (by default, the first option)

Streams

NameTypeDescriptionHold
$optionsstring[]Stream of menu options
$valuestringStream of selected value

Screenshot

Screenshot of the select component

Example

js
const sel = select(['one', 'two', 'three'], 'two');
sel.$value.subscribe((x) => console.log('sel $value:', x));

slider

tsx
function slider({
  values: number[],
  min: number,
  max: number,
  step: number,
  range: boolean | 'min' | 'max',
  float: boolean,
  vertical: boolean,
  pips: boolean,
  pipstep: number,
  formatter: (x: unknown) => unknown,
  continuous: boolean,
}): Slider;

A generic slider widget, allowing multiple thumbs.

Parameters

OptionTypeDescriptionRequiredDefault
valuesnumber[]The default values[0.2]
minnumberminimum value0
maxnumbermaximum value1
stepnumberstep size0.01
rangeboolean | 'min' | 'max'Specifies the slider bar display. If false, no bar is displayed. If true, the bar is displayed as a range between several values. If 'min' (resp. 'max'), the slider bar is displayed from the minimum (resp. 'maximum') value.'min'
floatbooleanspecifies if the value should be displayed in a floating indicator on hovertrue
verticalbooleandisplay the slider verticallyfalse
pipsbooleandisplay pips (ticks)false
pipstepnumberPip step sizeundefined
formatter(x: unknown) => unknownThe function used for formatting the pips and floating indicator(x) => x
continuousbooleanSpecify if values should be update continuously or on mouse release.true

Streams

NameTypeDescriptionHold
$valuesstringStream of selected value
$minstringStream of selected value
$maxstringStream of selected value
$stepstringStream of selected value

Screenshot

Screenshot of the slider component

Example

js
const slider = slider({
  values: [2, 8],
  min: 0,
  max: 10,
  pips: true,
  step: 1,
  range: true,
});
slider.$values.subscribe((x) => console.log('slider $values:', x));

text

tsx
function text(initial?: string): Text;

A generic GUI text display component accepting HTL strings.

Parameters

OptionTypeDescriptionRequired
initialstringInitial text

Streams

NameTypeDescriptionHold
$valuebooleanStream defining the text content

Screenshot

Screenshot of the toggle component

Example

js
const t = text(
  `Just some HTML text content...<br>
  Accepts HTML: <a href="https://marcelle.dev">Click me!</a>`,
);

textArea

tsx
function textArea(defaultValue: string, placeholder: string): TextArea;

A generic GUI text area component.

Parameters

OptionTypeDescriptionRequired
defaultValuestringInitial value
placeholderstringPlaceholder text

Streams

NameTypeDescriptionHold
$valuestringStream defining the textarea's value
$disabledbooleanStream defining if the textarea is disabled

Screenshot

Screenshot of the text-area component

Example

js
const comments = textArea('', 'Enter some comments');
comments.$value.subscribe(console.log);

textInput

tsx
function textInput(defaultValue?: string): TextInput;

A generic GUI text input component.

Parameters

OptionTypeDescriptionRequired
defaultValuestringInitial value

Streams

NameTypeDescriptionHold
$valuestringStream defining the input's value
$disabledbooleanStream defining if the input is disabled

Screenshot

Screenshot of the text-input component

Example

js
const label = textInput('myLabel');
label.title = 'Instance label';

label.$value.subscribe(console.log);

toggle

tsx
function toggle(text?: string): Toggle;

A generic GUI toggle (switch) component.

Parameters

OptionTypeDescriptionRequired
textstringThe text of the togggle

Streams

NameTypeDescriptionHold
$textbooleanStream defining the toggle text
$checkedbooleanStream defining if the toggle is checked
$disabledbooleanStream defining if the toggle is disabled

Screenshot

Screenshot of the toggle component

Example

js
const tog = toggle('Toggle Real-Time Prediction');
tog.$checked.subscribe((x) => console.log('toggle $checked:', x));

trainingProgress

tsx
function trainingProgress(m: Model): TrainingProgress;

Displays the progress of the training process for a given model.

Parameters

OptionTypeDescriptionRequired
mModelA machine learning model exposing a $training stream

Screenshot

Screenshot of the training-progress component

Example

js
const classifier = marcelle.mlp({ layers: [64, 32], epochs: 20 });
const prog = marcelle.trainingProgress(classifier);