Skip to content

🧪 ImageDataset

A Dataset for ImageLists as input and ImageLists, Tables or Columns as output.

Parent type: Dataset<ImageList, O>

Parameters:

Name Type Description Default
inputData ImageList The input ImageList -
outputData O The output data -
batchSize Int The batch size used for training 1
shuffle Boolean Whether the data should be shuffled after each epoch of training false

Type parameters:

Name Upper Bound Description Default
O Any? - -

Examples:

pipeline example {
    val image = Image.fromFile("example.png");
    val imageList = ImageList.fromImages([image]);
    val labels = Column("label", ["example"]);
    val dataset = ImageDataset(imageList, labels);
}
Stub code in ImageDataset.sdsstub

@Experimental
class ImageDataset<out O>(
    @PythonName("input_data") inputData: ImageList,
    @PythonName("output_data") outputData: O,
    @PythonName("batch_size") batchSize: Int = 1,
    shuffle: Boolean = false
) sub Dataset<ImageList, O> {
    /**
     * Get the input `ImageSize` of this dataset.
     */
    @PythonName("input_size") attr inputSize: ImageSize
    /**
     * Get the output size of this dataset.
     */
    @PythonName("output_size") attr outputSize: ImageSize

    /**
     * Get the input data of this dataset.
     *
     * @result input the input data of this dataset
     *
     * @example
     * pipeline example {
     *     val image = Image.fromFile("example.png");
     *     val imageList = ImageList.fromImages([image]);
     *     val labels = Column("label", ["example"]);
     *     val dataset = ImageDataset(imageList, labels);
     *     val input = dataset.getInput();
     * }
     */
    @Pure
    @PythonName("get_input")
    fun getInput() -> input: ImageList

    /**
     * Get the output data of this dataset.
     *
     * @result output the output data of this dataset
     *
     * @example
     * pipeline example {
     *     val image = Image.fromFile("example.png");
     *     val imageList = ImageList.fromImages([image]);
     *     val labels = Column("label", ["example"]);
     *     val dataset = ImageDataset(imageList, labels);
     *     val output = dataset.getOutput();
     * }
     */
    @Pure
    @PythonName("get_output")
    fun getOutput() -> output: O

    /**
     * Return a new `ImageDataset` with shuffled data.
     *
     * The original dataset is not modified.
     *
     * @result imageDataset the shuffled `ImageDataset`
     *
     * @example
     * pipeline example {
     *     val image = Image.fromFile("example.png");
     *     val imageList = ImageList.fromImages([image]);
     *     val labels = Column("label", ["example"]);
     *     val dataset = ImageDataset(imageList, labels);
     *     val shuffledDataset = dataset.shuffle();
     * }
     */
    @Pure
    fun shuffle() -> imageDataset: ImageDataset<O>

    /**
     * Create two image datasets by splitting the data of the current dataset.
     *
     * The first dataset contains a percentage of the data specified by `percentage_in_first`, and the second dataset
     * contains the remaining data. By default, the data is shuffled before splitting. You can disable this by setting
     * `shuffle` to False.
     *
     * The original dataset is not modified.
     *
     * @param percentageInFirst The percentage of data to include in the first dataset. Must be between 0 and 1.
     * @param shuffle Whether to shuffle the data before splitting.
     *
     * @result firstDataset The first dataset.
     * @result secondDataset The second dataset.
     */
    @Pure
    fun split(
        @PythonName("percentage_in_first") percentageInFirst: Float,
        shuffle: Boolean = true
    ) -> (firstDataset: ImageDataset<O>, secondDataset: ImageDataset<O>)
}

inputSize

Get the input ImageSize of this dataset.

Type: ImageSize

outputSize

Get the output size of this dataset.

Type: ImageSize

getInput

Get the input data of this dataset.

Results:

Name Type Description
input ImageList the input data of this dataset

Examples:

pipeline example {
    val image = Image.fromFile("example.png");
    val imageList = ImageList.fromImages([image]);
    val labels = Column("label", ["example"]);
    val dataset = ImageDataset(imageList, labels);
    val input = dataset.getInput();
}
Stub code in ImageDataset.sdsstub

@Pure
@PythonName("get_input")
fun getInput() -> input: ImageList

getOutput

Get the output data of this dataset.

Results:

Name Type Description
output O the output data of this dataset

Examples:

pipeline example {
    val image = Image.fromFile("example.png");
    val imageList = ImageList.fromImages([image]);
    val labels = Column("label", ["example"]);
    val dataset = ImageDataset(imageList, labels);
    val output = dataset.getOutput();
}
Stub code in ImageDataset.sdsstub

@Pure
@PythonName("get_output")
fun getOutput() -> output: O

shuffle

Return a new ImageDataset with shuffled data.

The original dataset is not modified.

Results:

Name Type Description
imageDataset ImageDataset<O> the shuffled ImageDataset

Examples:

pipeline example {
    val image = Image.fromFile("example.png");
    val imageList = ImageList.fromImages([image]);
    val labels = Column("label", ["example"]);
    val dataset = ImageDataset(imageList, labels);
    val shuffledDataset = dataset.shuffle();
}
Stub code in ImageDataset.sdsstub

@Pure
fun shuffle() -> imageDataset: ImageDataset<O>

split

Create two image datasets by splitting the data of the current dataset.

The first dataset contains a percentage of the data specified by percentage_in_first, and the second dataset contains the remaining data. By default, the data is shuffled before splitting. You can disable this by setting shuffle to False.

The original dataset is not modified.

Parameters:

Name Type Description Default
percentageInFirst Float The percentage of data to include in the first dataset. Must be between 0 and 1. -
shuffle Boolean Whether to shuffle the data before splitting. true

Results:

Name Type Description
firstDataset ImageDataset<O> The first dataset.
secondDataset ImageDataset<O> The second dataset.
Stub code in ImageDataset.sdsstub

@Pure
fun split(
    @PythonName("percentage_in_first") percentageInFirst: Float,
    shuffle: Boolean = true
) -> (firstDataset: ImageDataset<O>, secondDataset: ImageDataset<O>)