learning_model 1.0.35 → 1.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.bundle.js +1 -1
- package/dist/learning/base.d.ts +5 -1
- package/dist/learning/mobilenet.d.ts +5 -1
- package/dist/learning/mobilenet.js +3 -2
- package/dist/lib/learning/base.d.ts +5 -1
- package/dist/lib/learning/mobilenet.d.ts +5 -1
- package/lib/learning/base.ts +1 -1
- package/lib/learning/mobilenet.ts +5 -3
- package/package.json +1 -1
package/dist/learning/base.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ interface LearningInterface {
|
|
|
16
16
|
saveModel(handlerOrURL: io.IOHandler | string, config?: io.SaveConfig): Promise<void>;
|
|
17
17
|
running(): boolean;
|
|
18
18
|
ready(): boolean;
|
|
19
|
-
load(
|
|
19
|
+
load({ jsonURL, binFile, labels }: {
|
|
20
|
+
jsonURL: string;
|
|
21
|
+
binFile: io.LoadOptions | undefined;
|
|
22
|
+
labels: Array<string>;
|
|
23
|
+
}): Promise<void>;
|
|
20
24
|
}
|
|
21
25
|
export default LearningInterface;
|
|
@@ -34,7 +34,11 @@ declare class LearningMobilenet implements LearningInterface {
|
|
|
34
34
|
onTrainBegin: (log: any) => void;
|
|
35
35
|
onTrainEnd: (log: any) => void;
|
|
36
36
|
onEpochEnd: (epoch: number, logs: any) => void;
|
|
37
|
-
load(
|
|
37
|
+
load({ jsonURL, binFile, labels }: {
|
|
38
|
+
jsonURL: string;
|
|
39
|
+
binFile: io.LoadOptions | undefined;
|
|
40
|
+
labels: Array<string>;
|
|
41
|
+
}): Promise<void>;
|
|
38
42
|
addData(label: string, data: any): Promise<void>;
|
|
39
43
|
init(): Promise<void>;
|
|
40
44
|
train(): Promise<tf.History>;
|
|
@@ -69,13 +69,13 @@ class LearningMobilenet {
|
|
|
69
69
|
}
|
|
70
70
|
//
|
|
71
71
|
// 기존의 모델 로드
|
|
72
|
-
load(
|
|
72
|
+
load({ jsonURL, binFile, labels }) {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
74
|
if (labels.length <= 0) {
|
|
75
75
|
return Promise.reject(new Error('Labels length is 0'));
|
|
76
76
|
}
|
|
77
77
|
try {
|
|
78
|
-
this.model = yield tf.loadLayersModel(
|
|
78
|
+
this.model = yield tf.loadLayersModel(jsonURL);
|
|
79
79
|
this.labels = labels;
|
|
80
80
|
this.isReady = true;
|
|
81
81
|
this.model.summary();
|
|
@@ -182,6 +182,7 @@ class LearningMobilenet {
|
|
|
182
182
|
const inputData = this._preprocessedInputData(this.model);
|
|
183
183
|
console.log('this.imageTensors', this.imageTensors, inputData);
|
|
184
184
|
const targetData = this._preprocessedTargetData();
|
|
185
|
+
console.log('targetData', targetData);
|
|
185
186
|
const history = yield this.model.fit(inputData, targetData, {
|
|
186
187
|
epochs: this.epochs,
|
|
187
188
|
batchSize: this.batchSize,
|
|
@@ -16,6 +16,10 @@ interface LearningInterface {
|
|
|
16
16
|
saveModel(handlerOrURL: io.IOHandler | string, config?: io.SaveConfig): Promise<void>;
|
|
17
17
|
running(): boolean;
|
|
18
18
|
ready(): boolean;
|
|
19
|
-
load(
|
|
19
|
+
load({ jsonURL, binFile, labels }: {
|
|
20
|
+
jsonURL: string;
|
|
21
|
+
binFile: io.LoadOptions | undefined;
|
|
22
|
+
labels: Array<string>;
|
|
23
|
+
}): Promise<void>;
|
|
20
24
|
}
|
|
21
25
|
export default LearningInterface;
|
|
@@ -34,7 +34,11 @@ declare class LearningMobilenet implements LearningInterface {
|
|
|
34
34
|
onTrainBegin: (log: any) => void;
|
|
35
35
|
onTrainEnd: (log: any) => void;
|
|
36
36
|
onEpochEnd: (epoch: number, logs: any) => void;
|
|
37
|
-
load(
|
|
37
|
+
load({ jsonURL, binFile, labels }: {
|
|
38
|
+
jsonURL: string;
|
|
39
|
+
binFile: io.LoadOptions | undefined;
|
|
40
|
+
labels: Array<string>;
|
|
41
|
+
}): Promise<void>;
|
|
38
42
|
addData(label: string, data: any): Promise<void>;
|
|
39
43
|
init(): Promise<void>;
|
|
40
44
|
train(): Promise<tf.History>;
|
package/lib/learning/base.ts
CHANGED
|
@@ -45,7 +45,7 @@ interface LearningInterface {
|
|
|
45
45
|
ready(): boolean;
|
|
46
46
|
|
|
47
47
|
// 모델 로드
|
|
48
|
-
load(
|
|
48
|
+
load({jsonURL, binFile, labels}: {jsonURL :string, binFile: io.LoadOptions | undefined, labels : Array<string>}): Promise<void>;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export default LearningInterface;
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
import * as tf from '@tensorflow/tfjs';
|
|
8
8
|
import { io } from '@tensorflow/tfjs-core';
|
|
9
9
|
import LearningInterface from './base';
|
|
10
|
-
import { ImageToTensor } from './util';
|
|
11
10
|
|
|
12
11
|
class LearningMobilenet implements LearningInterface {
|
|
13
12
|
model: tf.LayersModel | null;
|
|
@@ -67,13 +66,13 @@ class LearningMobilenet implements LearningInterface {
|
|
|
67
66
|
|
|
68
67
|
//
|
|
69
68
|
// 기존의 모델 로드
|
|
70
|
-
public async load(
|
|
69
|
+
public async load({jsonURL, binFile, labels}: {jsonURL :string, binFile: io.LoadOptions | undefined, labels : Array<string>}): Promise<void> {
|
|
71
70
|
if (labels.length <= 0) {
|
|
72
71
|
return Promise.reject(new Error('Labels length is 0'));
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
try {
|
|
76
|
-
this.model = await tf.loadLayersModel(
|
|
75
|
+
this.model = await tf.loadLayersModel(jsonURL);
|
|
77
76
|
this.labels = labels;
|
|
78
77
|
this.isReady = true;
|
|
79
78
|
this.model.summary();
|
|
@@ -84,6 +83,7 @@ class LearningMobilenet implements LearningInterface {
|
|
|
84
83
|
|
|
85
84
|
}
|
|
86
85
|
|
|
86
|
+
|
|
87
87
|
// 학습 데이타 등록
|
|
88
88
|
public async addData(label: string, data: any): Promise<void> {
|
|
89
89
|
try {
|
|
@@ -179,6 +179,7 @@ class LearningMobilenet implements LearningInterface {
|
|
|
179
179
|
|
|
180
180
|
console.log('this.imageTensors', this.imageTensors, inputData);
|
|
181
181
|
const targetData = this._preprocessedTargetData();
|
|
182
|
+
console.log('targetData', targetData);
|
|
182
183
|
const history = await this.model.fit(inputData, targetData, {
|
|
183
184
|
epochs: this.epochs,
|
|
184
185
|
batchSize: this.batchSize,
|
|
@@ -282,6 +283,7 @@ class LearningMobilenet implements LearningInterface {
|
|
|
282
283
|
console.log('oneHotEncode', oneHotEncode);
|
|
283
284
|
return oneHotEncode
|
|
284
285
|
}
|
|
286
|
+
|
|
285
287
|
|
|
286
288
|
// 입력 이미지 데이타
|
|
287
289
|
private _preprocessedInputData(model: tf.LayersModel): tf.Tensor<tf.Rank> {
|