The LVM-Image-Aspect-Ratio Filter (DLC) component removes images with extreme aspect ratios from your training dataset. Use it to enforce consistent image proportions before training image generation models.
Supported computing resources
How it works
The component calculates the width-to-height ratio (W/H) for each image and filters out any image whose ratio falls outside the configured range. Images within the range are written to the output file; images outside the range are discarded. In most cases, the component is used for the subsequent training of image generation models.
Example: With Minimum Aspect Ratio set to 0.333 and Maximum Aspect Ratio set to 3.0:
| Image | Dimensions | Aspect ratio (W/H) | Result |
|---|---|---|---|
| img1 | 1920 x 1080 | 1.78 | Kept |
| img2 | 100 x 1000 | 0.10 | Filtered out (too narrow) |
| img3 | 3200 x 400 | 8.00 | Filtered out (too wide) |
Inputs and outputs
Input
Connect one of the following upstream components:
Read File Data — reads the Object Storage Service (OSS) path where your training data is stored.
Image Data OSS Path — configure this parameter to select the OSS directory where the image data is stored or to select the image metadata file.
Any image data preprocessing component — the output of an upstream preprocessing step can feed directly into this filter.
Output
The filtering results are written to the OSS path specified in Output File OSS Path. The output consists of three files:
| File | Description |
|---|---|
{name}.jsonl | The filtered output file. The filename is set by Output Filename. |
{name}_stats.jsonl | The state file. |
dj_run_yaml.yaml | The parameter configuration used during the run. |
Parameters
Configure the component in Machine Learning Designer. The following table describes all parameters.
| Tab | Parameter | Required | Default | Description |
|---|---|---|---|---|
| Field Settings | Image Data OSS Path | No | — | The OSS directory containing your image data. On the first run without an upstream component, select this directory manually. The component generates a metadata file meta.jsonl in the parent directory of the path you specify. For subsequent runs, select meta.jsonl directly instead of the directory. |
| Field Settings | Output File OSS Path | Yes | — | The OSS directory where filtering results are stored. |
| Field Settings | Output Filename | Yes | result.jsonl | The filename for the filtered output file. |
| Parameter Settings | Minimum Aspect Ratio (W/H) | Yes | 0.333 | Images with an aspect ratio below this value are filtered out. The value 0.333 corresponds approximately to a 1:3 portrait ratio. |
| Parameter Settings | Maximum Aspect Ratio (W/H) | Yes | 3.0 | Images with an aspect ratio above this value are filtered out. The value 3.0 corresponds to a 3:1 landscape ratio. |
| Execution Tuning | Number of Processes | Yes | 4 | The number of parallel processes for the filtering job. |
| Execution Tuning | Select Resource Group > Public Resource Group | No | — | The instance type (CPU or GPU) and virtual private cloud (VPC) for the job. We recommend that you use the CPU instance type to save costs. |
| Execution Tuning | Select Resource Group > Dedicated resource group | No | — | The number of vCPUs, memory, shared memory, and GPUs for the job. |
| Execution Tuning | Maximum Running Duration (seconds) | No | — | The maximum time the component is allowed to run. The job is terminated if this limit is exceeded. |