Skip to content

Commit 6db31d2

Browse files
committed
add and update component tests
1 parent 0f0fd86 commit 6db31d2

3 files changed

Lines changed: 149 additions & 44 deletions

File tree

web_ui/tests/features/project-models/mocks.ts

Lines changed: 103 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2887,27 +2887,16 @@ export const trainingConfiguration: TrainingConfigurationDTO = {
28872887
default_value: false,
28882888
},
28892889
{
2890-
key: 'max_rotate_degree',
2890+
key: 'degrees',
28912891
name: 'Rotation degrees',
28922892
type: 'float',
28932893
description:
28942894
'Maximum rotation angle in degrees for affine transformation. A random angle in the range [-max_rotate_degree, max_rotate_degree] will be applied. For example, max_rotate_degree=10 allows up to ±10 degrees rotation.',
2895-
value: 10.0,
2895+
value: 15.0,
28962896
default_value: 10.0,
28972897
min_value: 0.0,
28982898
max_value: null,
28992899
},
2900-
{
2901-
key: 'max_translate_ratio',
2902-
name: 'Horizontal translation',
2903-
type: 'float',
2904-
description:
2905-
'Maximum translation as a fraction of image width or height. A random translation in the range [-max_translate_ratio, max_translate_ratio] will be applied along both axes. For example, 0.1 allows up to ±10% translation.',
2906-
value: 0.1,
2907-
default_value: 0.1,
2908-
min_value: 0.0,
2909-
max_value: 1.0,
2910-
},
29112900
{
29122901
key: 'scaling_ratio_range',
29132902
name: 'Scaling ratio range',
@@ -2940,16 +2929,36 @@ export const trainingConfiguration: TrainingConfigurationDTO = {
29402929
default_value: true,
29412930
},
29422931
{
2943-
key: 'probability',
2944-
name: 'Probability',
2932+
key: 'max_translate_ratio',
2933+
name: 'Horizontal translation',
29452934
type: 'float',
29462935
description:
2947-
'Probability of applying horizontal flip. A value of 0.5 means each image has a 50% chance to be flipped horizontally.',
2948-
value: 0.5,
2949-
default_value: 0.5,
2936+
'Maximum translation as a fraction of image width or height. A random translation in the range [-max_translate_ratio, max_translate_ratio] will be applied along both axes. For example, 0.1 allows up to ±10% translation.',
2937+
value: 0.1,
2938+
default_value: 0.1,
29502939
min_value: 0.0,
29512940
max_value: 1.0,
29522941
},
2942+
{
2943+
key: 'scaling_ratio_range',
2944+
name: 'Scaling ratio range',
2945+
type: 'array',
2946+
description:
2947+
'Range (min, max) of scaling factors to apply during affine transformation. Both values should be > 0.0. For example, (0.8, 1.2) will randomly scale the image between 80% and 120% of its original size.',
2948+
value: [0.5, 1.5],
2949+
default_value: [0.5, 1.5],
2950+
},
2951+
{
2952+
key: 'max_shear_degree',
2953+
name: 'Maximum shear degree',
2954+
type: 'float',
2955+
description:
2956+
'Maximum absolute shear angle in degrees to apply during affine transformation. A random shear in the range [-max_shear_degree, max_shear_degree] will be applied.',
2957+
value: 2.0,
2958+
default_value: 2.0,
2959+
min_value: null,
2960+
max_value: null,
2961+
},
29532962
],
29542963
random_vertical_flip: [
29552964
{
@@ -3274,14 +3283,72 @@ export const expectedTrainingConfiguration: TrainingConfigurationUpdatePayloadDT
32743283
],
32753284
},
32763285
augmentation: {
3277-
center_crop: [
3286+
color_jitter: [
3287+
{
3288+
key: 'enable',
3289+
value: true,
3290+
},
3291+
{
3292+
key: 'brightness',
3293+
value: [0.876, 1.091],
3294+
},
3295+
{
3296+
key: 'contrast',
3297+
value: [0.5, 1.5],
3298+
},
3299+
{
3300+
key: 'saturation',
3301+
value: [0.5, 1.5],
3302+
},
3303+
{
3304+
key: 'hue',
3305+
value: [-0.05, 0.05],
3306+
},
3307+
{
3308+
key: 'probability',
3309+
value: 0.5,
3310+
},
3311+
],
3312+
gaussian_blur: [
32783313
{
32793314
key: 'enable',
32803315
value: false,
32813316
},
32823317
{
3283-
key: 'ratio',
3284-
value: 0.6,
3318+
key: 'kernel_size',
3319+
value: 5,
3320+
},
3321+
{
3322+
key: 'sigma',
3323+
value: [0.1, 2],
3324+
},
3325+
{
3326+
key: 'probability',
3327+
value: 0.5,
3328+
},
3329+
],
3330+
gaussian_noise: [
3331+
{
3332+
key: 'enable',
3333+
value: false,
3334+
},
3335+
{
3336+
key: 'mean',
3337+
value: 0,
3338+
},
3339+
{
3340+
key: 'sigma',
3341+
value: 0.1,
3342+
},
3343+
{
3344+
key: 'probability',
3345+
value: 0.5,
3346+
},
3347+
],
3348+
iou_random_crop: [
3349+
{
3350+
key: 'enable',
3351+
value: true,
32853352
},
32863353
],
32873354
random_affine: [
@@ -3294,16 +3361,12 @@ export const expectedTrainingConfiguration: TrainingConfigurationUpdatePayloadDT
32943361
value: 15,
32953362
},
32963363
{
3297-
key: 'translate_x',
3298-
value: 0,
3299-
},
3300-
{
3301-
key: 'translate_y',
3302-
value: 0,
3364+
key: 'scaling_ratio_range',
3365+
value: [0.5, 1.5],
33033366
},
33043367
{
3305-
key: 'scale',
3306-
value: 1,
3368+
key: 'max_shear_degree',
3369+
value: 2,
33073370
},
33083371
],
33093372
tiling: [
@@ -3321,9 +3384,19 @@ export const expectedTrainingConfiguration: TrainingConfigurationUpdatePayloadDT
33213384
},
33223385
{
33233386
key: 'tile_overlap',
3324-
value: 64,
3387+
value: 0.2,
33253388
},
33263389
],
3390+
random_horizontal_flip: [
3391+
{ key: 'enable', value: true },
3392+
{ key: 'max_translate_ratio', value: 0.1 },
3393+
{ key: 'scaling_ratio_range', value: [0.5, 1.5] },
3394+
{ key: 'max_shear_degree', value: 2 },
3395+
],
3396+
random_vertical_flip: [
3397+
{ key: 'enable', value: false },
3398+
{ key: 'probability', value: 0.5 },
3399+
],
33273400
},
33283401
},
33293402
training: [

web_ui/tests/features/project-models/train-model.spec.ts

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,11 @@ test.describe('Train model', () => {
155155
trainingSize: 71,
156156
});
157157

158-
await trainModelPage.changeSubsetRange('start', 10);
159-
await trainModelPage.changeSubsetRange('end', 5);
158+
const distributionSlider = page.getByText('Distribution 70/20/10%');
159+
await trainModelPage.changeSubsetRange(distributionSlider, 'start', 10);
160+
161+
const refreshedDistributionSlider = page.getByText('Distribution 60/30/10%');
162+
await trainModelPage.changeSubsetRange(refreshedDistributionSlider, 'end', 5);
160163

161164
await expectTrainingSubsetsDistribution(page, {
162165
testSubset: 15,
@@ -169,15 +172,38 @@ test.describe('Train model', () => {
169172
trainingSize: 61,
170173
});
171174

175+
await page.getByRole('button', { name: 'Custom' }).click();
172176
await trainModelPage.changeNumberParameter('Tile size', 128);
173177
await expect(trainModelPage.getNumberParameter('Tile size')).toHaveValue('128');
174178

175-
await expect(trainModelPage.getBooleanParameter('Enable center crop')).toBeChecked();
176-
await expect(trainModelPage.getNumberParameter('Crop ratio')).toBeEnabled();
179+
await expect(trainModelPage.getBooleanParameter('Enable random IoU crop')).toBeChecked();
177180

178-
await trainModelPage.toggleEnableParameter('Enable center crop');
179-
await expect(trainModelPage.getBooleanParameter('Enable center crop')).not.toBeChecked();
180-
await expect(trainModelPage.getNumberParameter('Crop ratio')).toBeDisabled();
181+
await trainModelPage.toggleEnableParameter('Enable color jitter');
182+
183+
await expect(page.getByRole('slider', { name: 'Minimum Change Brightness' })).toHaveValue('0.875');
184+
await expect(page.getByRole('slider', { name: 'Maximum Change Brightness' })).toHaveValue('1.125');
185+
186+
const brightnessStart = page.getByRole('button', {
187+
name: 'Increase Change Brightness range start range value',
188+
});
189+
await brightnessStart.click();
190+
191+
const brightnessSlider = page.getByLabel('Change Brightness range value');
192+
brightnessSlider.click();
193+
194+
const endRange = brightnessSlider.getByRole('presentation').nth(2);
195+
196+
await endRange.click();
197+
const box = await endRange.boundingBox();
198+
199+
if (box) {
200+
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
201+
await page.mouse.down();
202+
await page.mouse.move(box.x + box.width / 2 - 30, box.y + box.height / 2);
203+
await page.mouse.up();
204+
} else {
205+
throw new Error('Could not get bounding box for endRange handle');
206+
}
181207

182208
await expect(trainModelPage.getToggleFilter('Minimum annotation pixels')).toBeChecked();
183209
await expect(trainModelPage.getNumberParameter('Minimum annotation pixels')).toBeDisabled();
@@ -269,7 +295,9 @@ test.describe('Train model', () => {
269295

270296
await trainModelPage.selectTab('Data management');
271297

272-
await trainModelPage.changeSubsetRange('start', 10);
298+
const distributionSlider = page.getByText('Distribution 70/20/10%');
299+
await trainModelPage.changeSubsetRange(distributionSlider, 'start', 10);
300+
273301
await expectTrainingSubsetsDistribution(page, {
274302
testSubset: 10,
275303
validationSubset: 30,
@@ -381,8 +409,11 @@ test.describe('Train model', () => {
381409
trainingSize: 71,
382410
});
383411

384-
await trainModelPage.changeSubsetRange('start', 10);
385-
await trainModelPage.changeSubsetRange('end', 5);
412+
const distributionSlider = page.getByText('Distribution 70/20/10%');
413+
await trainModelPage.changeSubsetRange(distributionSlider, 'start', 10);
414+
415+
const refreshedDistributionSlider = page.getByText('Distribution 60/30/10%');
416+
await trainModelPage.changeSubsetRange(refreshedDistributionSlider, 'end', 5);
386417

387418
await expectTrainingSubsetsDistribution(page, {
388419
testSubset: 15,
@@ -498,7 +529,8 @@ test.describe('Train model', () => {
498529

499530
await trainModelPage.selectTab('Data management');
500531

501-
await trainModelPage.changeSubsetRange('start', 10);
532+
const distributionSlider = page.getByText('Distribution 70/20/10%');
533+
await trainModelPage.changeSubsetRange(distributionSlider, 'start', 10);
502534
await expectTrainingSubsetsDistribution(page, {
503535
testSubset: 10,
504536
validationSubset: 30,

web_ui/tests/fixtures/page-objects/train-model-dialog-page.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (C) 2022-2025 Intel Corporation
22
// LIMITED EDGE SOFTWARE DISTRIBUTION LICENSE
33

4-
import { Page } from '@playwright/test';
4+
import { Locator, Page } from '@playwright/test';
55

66
import { ModelConfigurationOption } from '../../../src/pages/project-details/components/project-models/legacy-train-model-dialog/model-templates-selection/utils';
77

@@ -16,8 +16,8 @@ export class TrainModelDialogPage {
1616
await this.page.getByRole('button', { name: /advanced settings/i }).click();
1717
}
1818

19-
async changeSubsetRange(range: 'start' | 'end', iterations: number) {
20-
await this.page.getByLabel(range === 'start' ? 'Start range' : 'End range').click();
19+
async changeSubsetRange(slider: Locator, range: 'start' | 'end', iterations: number) {
20+
await slider.getByLabel(range === 'start' ? 'Start range' : 'End range').click();
2121

2222
for (let i = 0; i < iterations; i++) {
2323
await this.page.keyboard.press('ArrowLeft');

0 commit comments

Comments
 (0)