Experiment

Methods:


train_test_split

Signature

train_test_split(
   prop: float = 0.8
)

Description

Train test split

Examples

    experiment.train_test_split()

Arguments

  • prop (float, optional) : Percentage of data for training set. Defaults to 0.8.

Raises

  • ResourceNotFoundError : No annotations. You have to run the .download_annotations() first.

Returns

A tuple with all of this information (
list of train picture files,
list of test picture files,
list of train picture ids,
list of test picture ids,
dict of repartition of classes for train set,
dict of repartition of classes for test set,
list of labels
)


download

Signature

download(
   name: str, target_path: str = '', large: bool = None
)

Description

Download an experiment's artifact to a given target_path.

Examples

    experiment.download("model-latest", "myDir")
    file_list = os.path.listdir("myDir")
    print(file_list)
    >>> ["saved_model.zip"]

Arguments

  • name (str) : Name of the artifact to download

  • target_path (str, optional) : Path to download the file to, default to cwd. Defaults to ''.

  • large (bool, optional) : If download fail with large=False, try again with large=True.
    Defaults to None.


get_base_model

Signature

get_base_model()

Description

Retrieve the base model of this experiment.

Examples

    model = experiment.get_base_model()

Returns

A Model object representing the base model.


get_log

Signature

get_log(
   name: str
)

Description

Get data for a given log in this experiment

Examples

    parameters = experiment.get_log("parameters")
    print(parameters)
    >>> {
        "batch_size":4,
        "epochs":1000
    }

Arguments

  • name (str) : name of the log to retrieve

Returns

A dict or list of the log you logged with given name


generate_labelmap

Signature

generate_labelmap()

Description

Generate a labelmap in the pbtxt format.

Generate labelmap in the current working directory and save the dictionnary in
experiment.label_map

Examples

    experiment.generate_labelmap()

Raises

  • ResourceNotFoundError : You have to call the .download_annotations() first.

  • ResourceNotFoundError : Path to write labelmap file not found.


download_annotations

Signature

download_annotations(
   option: str = 'all'
)

Description

Download the annotation of the dataset attached to the experiment.
The method stores the dict containing the annotations in experiment.dict_annotations attribute.

Examples

    annotation_dict = experiment.download_annotations("accepted")

Arguments

  • option (str, optional) : Whether to download only accepted annotations or every annotations
    . Defaults to "all".

Raises

  • ResourceNotFoundError : No annotations for the attached dataset.

Returns

A dict containing all the annotations in the Picsellia format.


list_artifacts

Signature

list_artifacts()

Description

List all stored artifacts in the experiment.

Examples

    artifacts = my_experiment.list_artifacts()

Returns

A list of artifact infos as dict like
{
'id':str,
'name':str,
'object_name':str,
'large':bool
}


delete_artifact

Signature

delete_artifact(
   name: str
)

Description

Delete artifact from experiment

:warning: The file of the artifact will be removed from our servers.

Examples

    experiment.delete_artifact("saved-model")

Arguments

  • name (str) : Name of the artifact

publish

Signature

publish(
   name: str
)

Description

Publish an Experiment as a Model to your registry.

Examples

    model = experiment.publish("awesome-model")
    model.update(framework="tensorflow")

Arguments

  • name (str) : Target Name for the model in the registry.

Returns

A Model just created from the experiment


get_dataset

Signature

get_dataset()

Description

Retrieve the dataset used for this experiment.

Examples

    my_dataset = experiment.get_dataset()

Returns

A Dataset object representing the dataset used.


get_artifact

Signature

get_artifact(
   name: str
)

Description

Retrieve an artifact information.

Examples

    model_artifact = experiment.get_artifact("model-latest")
    print(model_artifact)
    >>> {
            "id":137,
            "name":"model-latest",
            "object_name":"d67924a0-7757-48ed-bf7a-322b745e917e/saved_model.zip",
            "large":True
    }

Arguments

  • name (str) : Name of the artifact to retrieve

Returns

List of artifact info as dict like
{
"id":str,
"name":str,
"object_name":str,
"large":bool
}


launch

Signature

launch(
   gpus: int = 0
)

Description

Launch a job on a remote environment with this experiment.

:information-source: The remote environment has to be setup prior launching the experiment.
It defaults to our remote training engine.

Examples

    experiment.launch()

Arguments

  • gpus (int, optional) : Number of GPU to use for the training. Defaults to 0.

update

Signature

update(
   **kwargs
)

Description

Update this experiment with given keys.

Examples

    my_experiment.update(description="First try Yolov5")

get_resource_url_on_platform

Signature

get_resource_url_on_platform()

Description

Get platform url of this resource.

Examples

    print(foo_dataset.get_resource_url_on_platform())
    >>> https://app.picsellia.com/experiment/62cffb84-b92c-450c-bc37-8c4dd4d0f590

Returns

Url on Platform for this resource


delete_all_logs

Signature

delete_all_logs()

Description

Delete everything that has been logged.

Delete everything that has been logged (using .log()) into this experiment method.

Examples

    experiment.delete_all_logs()

download_pictures

Signature

download_pictures(
   max_workers: int = 20
)

Description

Download the picture from the dataset attached to the experiment.
It download only the pictures corresponding to the annotations fetched with the .download_annotations
method. This prevent to download unnecessary images from the dataset.
If you wish to to download the whole dataset, we recommend you to use the
client methods get_dataset() and .download() on the retrieved object.

Examples

    experiment.download_pictures()

Raises

  • ResourceNotFoundError : You have to run the .download_annotations() method first.

delete

Signature

delete()

Description

Delete this experiment

Examples

    my_experiment.delete()

delete_log

Signature

delete_log(
   name: str
)

Description

Delete log with given name in the experiment

Examples

    experiment.delete_log("parameters")

Arguments

  • name (str) : name of the log to delete

list_logs

Signature

list_logs()

Description

List everything that has been logged.

List everything that has been logged to an experiment using the .log() method.

Examples

    logs = experiment.list_logs()
    print(logs[0])
    >>> {
        "id":137,
        "date_created":"2021-09-06T10:47:56.569221Z",
        "last_update":"2021-09-06T10:47:56.569221Z",
        "name":"parameters",
        "type":"table",
        "data":{
            "batch_size":4,
            "epochs":1000
        }
    }

Returns

A list of logs objects as dict like {
"id":int,
"date_created":str,
"last_update":str,
"name":str,
"type":str,
"data":Union[list, dict]
}


get_base_experiment

Signature

get_base_experiment()

Description

Retrieve the base experiment of this experiment.

Examples

    base_exp = experiment.get_base_experiment()

Returns

An Experiment object representing the base experiment.


log

Signature

log(
   name: str, data: Any, type: str = None, replace: bool = False
)

Description

Log (record) anything to an experiment.

Record something to an experiment.
It will then be saved and displayed.

Examples

    parameters = {
        "batch_size":4,
        "epochs":1000
    }
    exp.log("parameters", parameters, type="table")

Arguments

  • name (str) : Name of the log.

  • data (Any) : Data to be saved.

  • type (str, optional) : Type of the data to log.
    This will condition how it is displayed in the experiment dashboard. Defaults to None.

  • replace (bool, optional) : Whether to replace the current value of the log. Defaults to False.

Raises

  • Exception : Impossible to upload the file when logging an image.

delete_all_artifacts

Signature

delete_all_artifacts()

Description

Delete all stored artifacts for experiment

:warning: DANGER ZONE: This will definitely remove the artifacts from our servers

Examples

    experiment.delete_all_artifacts()

store

Signature

store(
   name: str, path: str = None, zip: bool = False
)

Description

Store an artifact and attach it to the experiment.

Examples

    # Zip and store a folder as an artifact for the experiment
    # you can choose an arbitrary name or refer to our 'namespace'
    # for certain artifacts to have a custom behavior

    trained_model_path = "my_experiment/saved_model"
    experiment.store("model-latest", trained_model_path, zip=True)

Arguments

  • name (str) : name for the artifact. Defaults to "".

  • path (str) : path to the file or folder. Defaults to None.

  • zip (bool, optional) : Whether or not to compress the file to a zip file. Defaults to False.

Raises

  • FileNotFoundError : No file found at the given path