learning_model 1.0.28 → 1.0.30
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/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/learning/base.d.ts +3 -2
- package/dist/learning/image.d.ts +3 -1
- package/dist/learning/image.js +23 -12
- package/dist/learning/mobilenet.d.ts +49 -0
- package/dist/learning/mobilenet.js +317 -0
- package/dist/learning/mobilenet.test.d.ts +1 -0
- package/dist/learning/mobilenet.test.js +77 -0
- package/dist/learning/mobilenet_image.d.ts +3 -1
- package/dist/learning/mobilenet_image.js +5 -6
- package/dist/learning/util.js +1 -0
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/learning/base.d.ts +3 -2
- package/dist/lib/learning/image.d.ts +3 -1
- package/dist/lib/learning/mobilenet.d.ts +49 -0
- package/dist/lib/learning/mobilenet.test.d.ts +1 -0
- package/dist/lib/learning/mobilenet_image.d.ts +3 -1
- package/lib/index.ts +2 -1
- package/lib/learning/base.ts +4 -4
- package/lib/learning/image.ts +26 -13
- package/lib/learning/mobilenet.test.ts +44 -0
- package/lib/learning/mobilenet.ts +322 -0
- package/lib/learning/mobilenet_image.ts +7 -6
- package/lib/learning/util.ts +1 -0
- package/package.json +1 -1
- package/yarn-error.log +10 -10
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
///////////////////////////////////////////////////////////////////////////
|
|
6
6
|
|
|
7
7
|
import * as tf from '@tensorflow/tfjs';
|
|
8
|
+
import { io } from '@tensorflow/tfjs-core';
|
|
8
9
|
import LearningInterface from './base';
|
|
9
10
|
import { ImageToTensor } from './util';
|
|
10
11
|
|
|
@@ -59,6 +60,8 @@ class LearningMobilenetImage implements LearningInterface {
|
|
|
59
60
|
|
|
60
61
|
public onTrainEnd: (log: any) => void = () => {};
|
|
61
62
|
|
|
63
|
+
public onEpochEnd: (epoch: number, logs: any) => void = () => {};
|
|
64
|
+
|
|
62
65
|
|
|
63
66
|
// 학습 데이타 등록
|
|
64
67
|
public async addData(label: string, data: any): Promise<void> {
|
|
@@ -139,7 +142,6 @@ class LearningMobilenetImage implements LearningInterface {
|
|
|
139
142
|
|
|
140
143
|
// 추론하기
|
|
141
144
|
public async infer(data: any): Promise<Map<string, number>> {
|
|
142
|
-
const threshold = 1e-20; // 임계값 설정
|
|
143
145
|
if (this.model === null) {
|
|
144
146
|
return Promise.reject(new Error('Model is Null'));
|
|
145
147
|
}
|
|
@@ -154,12 +156,11 @@ class LearningMobilenetImage implements LearningInterface {
|
|
|
154
156
|
for (let i = 0; i < predictionsData.length; i++) {
|
|
155
157
|
const className = this.labels[i]; // 클래스 이름
|
|
156
158
|
const probability = predictionsData[i];
|
|
157
|
-
const result = Math.abs(probability) < threshold ? 0 : probability;
|
|
158
159
|
const existingProbability = classProbabilities.get(className);
|
|
159
160
|
if (existingProbability !== undefined) {
|
|
160
|
-
classProbabilities.set(className, existingProbability +
|
|
161
|
+
classProbabilities.set(className, existingProbability + probability);
|
|
161
162
|
} else {
|
|
162
|
-
classProbabilities.set(className,
|
|
163
|
+
classProbabilities.set(className, probability);
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
166
|
console.log('Class Probabilities:', classProbabilities);
|
|
@@ -171,12 +172,12 @@ class LearningMobilenetImage implements LearningInterface {
|
|
|
171
172
|
|
|
172
173
|
|
|
173
174
|
// 모델 저장
|
|
174
|
-
public async saveModel(): Promise<void> {
|
|
175
|
+
public async saveModel(handlerOrURL: io.IOHandler | string, config?: io.SaveConfig): Promise<void> {
|
|
175
176
|
console.log('saved model');
|
|
176
177
|
if (!this.isTrainedDone) {
|
|
177
178
|
return Promise.reject(new Error('Train is not done status'));
|
|
178
179
|
}
|
|
179
|
-
await this.model?.save(
|
|
180
|
+
await this.model?.save(handlerOrURL, config);
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
|
package/lib/learning/util.ts
CHANGED
package/package.json
CHANGED
package/yarn-error.log
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
Arguments:
|
|
2
|
-
/Users/
|
|
2
|
+
/Users/user/.nvm/versions/node/v14.17.3/bin/node /usr/local/Cellar/yarn/1.22.10/libexec/bin/yarn.js start
|
|
3
3
|
|
|
4
4
|
PATH:
|
|
5
|
-
/Users/
|
|
5
|
+
/Users/user/.local/bin:/usr/local/Cellar/pyenv-virtualenv/1.2.1/shims:/Users/user/.pyenv/shims:/Users/user/.pyenv/bin:/usr/local/opt/openssl@1.1/bin:/Users/user/.nvm/versions/node/v14.17.3/bin:/Users/user/go/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/go/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin/
|
|
6
6
|
|
|
7
7
|
Yarn version:
|
|
8
8
|
1.22.10
|
|
9
9
|
|
|
10
10
|
Node version:
|
|
11
|
-
|
|
11
|
+
14.17.3
|
|
12
12
|
|
|
13
13
|
Platform:
|
|
14
14
|
darwin x64
|
|
15
15
|
|
|
16
16
|
Trace:
|
|
17
17
|
Error: Failed to replace env in config: ${NODE_AUTH_TOKEN}
|
|
18
|
-
at /usr/local/
|
|
18
|
+
at /usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:98870:13
|
|
19
19
|
at String.replace (<anonymous>)
|
|
20
|
-
at envReplace (/usr/local/
|
|
21
|
-
at Function.normalizeConfig (/usr/local/
|
|
22
|
-
at NpmRegistry.<anonymous> (/usr/local/
|
|
20
|
+
at envReplace (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:98865:16)
|
|
21
|
+
at Function.normalizeConfig (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:31887:69)
|
|
22
|
+
at NpmRegistry.<anonymous> (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:31917:34)
|
|
23
23
|
at Generator.next (<anonymous>)
|
|
24
|
-
at step (/usr/local/
|
|
25
|
-
at /usr/local/
|
|
24
|
+
at step (/usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:310:30)
|
|
25
|
+
at /usr/local/Cellar/yarn/1.22.10/libexec/lib/cli.js:321:13
|
|
26
26
|
|
|
27
27
|
npm manifest:
|
|
28
28
|
{
|
|
29
29
|
"name": "learning_model",
|
|
30
|
-
"version": "1.0.
|
|
30
|
+
"version": "1.0.28",
|
|
31
31
|
"description": "learning model develop",
|
|
32
32
|
"main": "dist/index.js",
|
|
33
33
|
"types": "dist/index.d.ts",
|