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.
@@ -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 + result);
161
+ classProbabilities.set(className, existingProbability + probability);
161
162
  } else {
162
- classProbabilities.set(className, result);
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('localstorage://my-model');
180
+ await this.model?.save(handlerOrURL, config);
180
181
  }
181
182
 
182
183
 
@@ -7,6 +7,7 @@ export function ImageToTensor(data: any): tf.Tensor3D {
7
7
  if (data instanceof tf.Tensor) {
8
8
  tensor = data;
9
9
  } else {
10
+ // MobileNet 모델 로드
10
11
  tensor = tf.browser.fromPixels(data);
11
12
  }
12
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "learning_model",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "description": "learning model develop",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/yarn-error.log CHANGED
@@ -1,33 +1,33 @@
1
1
  Arguments:
2
- /Users/jeongseong-gyun/.nvm/versions/node/v16.11.1/bin/node /usr/local/bin/yarn start
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/jeongseong-gyun/.nvm/versions/node/v16.11.1/bin:/Users/jeongseong-gyun/local/bin:/usr/local/Cellar/pyenv-virtualenv/1.1.5/shims:/Users/jeongseong-gyun/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Library/Apple/usr/bin:/usr/local/go/bin:/Users/jeongseong-gyun/go/bin:/Users/jeongseong-gyun/Documents/flutter/bin:/Users/jeongseong-gyun/Documents/Work/sonar-scanner-4.6.0.2311-macosx/bin
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
- 16.11.1
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/lib/node_modules/yarn/lib/cli.js:98430:13
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/lib/node_modules/yarn/lib/cli.js:98425:16)
21
- at Function.normalizeConfig (/usr/local/lib/node_modules/yarn/lib/cli.js:31887:69)
22
- at NpmRegistry.<anonymous> (/usr/local/lib/node_modules/yarn/lib/cli.js:31917:34)
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/lib/node_modules/yarn/lib/cli.js:310:30)
25
- at /usr/local/lib/node_modules/yarn/lib/cli.js:321:13
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.26",
30
+ "version": "1.0.28",
31
31
  "description": "learning model develop",
32
32
  "main": "dist/index.js",
33
33
  "types": "dist/index.d.ts",