Skip to content

Commit 01f2a45

Browse files
【fix】 修复机器学习ut 报错 review by songym
1 parent 5e416be commit 01f2a45

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

test/common/thirdparty/ai/BinaryClassificationSpec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ describe('binary classification', () => {
1717
it('predict', (done) => {
1818
var params = {
1919
modelUrl: 'http://fakeurl/model.json',
20-
image: document.querySelector('#demo')
20+
image: document.querySelector('#demo'),
21+
backend: 'cpu'
2122
};
2223
var binaryClassification = new BinaryClassification(params);
2324
expect(binaryClassification).not.toBeNull();
2425
expect(binaryClassification.modelUrl).toBe(params.modelUrl);
25-
expect(binaryClassification.backend).toBe('webgl');
26+
expect(binaryClassification.backend).toBe('cpu');
2627
spyOn(tfconv, 'loadGraphModel').and.callFake((modelUrl) => {
2728
expect(modelUrl).toBe(params.modelUrl);
2829
const model = {

test/common/thirdparty/ai/LandcoverClassificationSpec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ describe('landcover classification', () => {
1717
it('predict', (done) => {
1818
var params = {
1919
modelUrl: 'http://fakeurl/model.json',
20-
image: window.document.querySelector('#demo')
20+
image: window.document.querySelector('#demo'),
21+
backend: 'cpu'
2122
};
2223
var landcoverClassification = new LandcoverClassification(params);
2324
expect(landcoverClassification).not.toBeNull();
2425
expect(landcoverClassification.modelUrl).toBe(params.modelUrl);
25-
expect(landcoverClassification.backend).toBe('webgl');
26+
expect(landcoverClassification.backend).toBe('cpu');
2627

2728
spyOn(tfconv, 'loadGraphModel').and.callFake((modelUrl) => {
2829
expect(modelUrl).toBe(params.modelUrl);

test/common/thirdparty/ai/ObjectDetectionSpec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,16 @@ describe('object detection', () => {
1717
it('predict', (done) => {
1818
var params = {
1919
modelUrl: 'http://fakeurl/model.json',
20-
image: document.querySelector('#demo')
20+
image: document.querySelector('#demo'),
21+
backend: 'cpu'
2122
};
2223
var objectDetection = new ObjectDetection(params);
2324
expect(objectDetection).not.toBeNull();
2425
expect(objectDetection.modelUrl).toBe(params.modelUrl);
25-
expect(objectDetection.backend).toBe('webgl');
26+
expect(objectDetection.backend).toBe('cpu');
2627
spyOn(tfconv, 'loadGraphModel').and.callFake((modelUrl) => {
2728
expect(modelUrl).toBe(params.modelUrl);
2829
const model = {
29-
// const score = result[3].arraySync();
30-
// const bbox = result[2].arraySync();
31-
// const delta = result[1].arraySync();
3230
executeAsync: (x) => {
3331
return [
3432
{},

test/common/thirdparty/ai/WebMachineLearningSpec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ describe('WebMachineLearning', () => {
1818
it('predict', (done) => {
1919
var params = {
2020
modelUrl: 'ttp://fakeurl/model.json',
21-
image: window.document.querySelector('#demo')
21+
image: window.document.querySelector('#demo'),
22+
backend: 'cpu'
2223
};
2324
var binaryClassification = new BinaryClassification(params);
2425
expect(binaryClassification).not.toBeNull();
2526
expect(binaryClassification.modelUrl).toBe(params.modelUrl);
26-
expect(binaryClassification.backend).toBe('webgl');
27+
expect(binaryClassification.backend).toBe('cpu');
2728
spyOn(tfconv, 'loadGraphModel').and.callFake((modelUrl) => {
2829
expect(modelUrl).toBe(params.modelUrl);
2930
const model = {

0 commit comments

Comments
 (0)