Skip to content

Commit 0c89caf

Browse files
Upgrade coco-ssd to 3.0.0-rc.1 (#564)
* Upgrade coco-ssd to 3.0.0-rc.1 * fix * fix * fix * fix * fix * fix * fix * fix * address comments
1 parent 16848fe commit 0c89caf

File tree

7 files changed

+78
-97
lines changed

7 files changed

+78
-97
lines changed

coco-ssd/demo/README.md

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,47 +16,36 @@ Install dependencies:
1616
yarn
1717
```
1818

19-
Launch a development server, and watch files for changes. This command will also automatically open
20-
the demo app in your browser.
19+
Build the coco-ssd model locally which the demo depends on:
2120

2221
```sh
23-
yarn watch
22+
yarn build-deps
2423
```
2524

26-
## If you are developing the model locally and want to test the changes in the demo
27-
28-
`cd` into the coco-ssd/ folder:
29-
30-
```sh
31-
cd coco-ssd
32-
```
25+
Launch a development server, and watch files for changes. This command will also automatically open
26+
the demo app in your browser.
3327

34-
Install dependencies:
3528
```sh
36-
yarn
29+
yarn watch
3730
```
3831

39-
Publish coco-ssd locally:
40-
```sh
41-
yarn publish-local
42-
```
32+
## If you are developing the model locally and want to test the changes in the demo
4333

44-
`cd` into this directory (coco-ssd/demo) and install dependencies:
34+
`cd` into the coco-ssd/demo folder:
4535

4636
```sh
47-
cd demo
48-
yarn
37+
cd coco-ssd/demo
4938
```
5039

51-
Link the package published from the publish step above:
40+
Rebuild coco-ssd locally:
5241
```sh
53-
yarn link-local
42+
yarn build-deps
5443
```
5544

5645
Start the dev demo server:
5746
```sh
5847
yarn watch
5948
```
6049

61-
To get future updates from the `coco-ssd` source code, just run `yarn publish-local` in the coco-ssd/
50+
To get future updates from the `coco-ssd` source code, just run `yarn build-deps` in the coco-ssd/demo
6251
folder again.

coco-ssd/demo/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
* limitations under the License.
1515
* =============================================================================
1616
*/
17-
import * as cocoSsd from '@tensorflow-models/coco-ssd'
18-
import * as cpu from '@tensorflow/tfjs-backend-cpu'
19-
import * as webgl from '@tensorflow/tfjs-backend-webgl'
17+
import '@tensorflow/tfjs-backend-cpu';
18+
import '@tensorflow/tfjs-backend-webgl';
19+
20+
import * as cocoSsd from '@tensorflow-models/coco-ssd';
2021

2122
import imageURL from './image1.jpg';
2223
import image2URL from './image2.jpg';
2324

2425
let modelPromise;
25-
let baseModel = 'lite_mobilenet_v2';
2626

2727
window.onload = () => modelPromise = cocoSsd.load();
2828

coco-ssd/demo/package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@
99
"node": ">=8.9.0"
1010
},
1111
"dependencies": {
12-
"@tensorflow-models/coco-ssd": "2.1.0",
13-
"@tensorflow/tfjs-converter": "2.0.1",
14-
"@tensorflow/tfjs-core": "2.0.1",
15-
"@tensorflow/tfjs-backend-cpu": "2.0.1",
16-
"@tensorflow/tfjs-backend-webgl": "2.0.1",
12+
"@tensorflow-models/coco-ssd": "link:../dist",
13+
"@tensorflow/tfjs-backend-cpu": "^3.0.0-rc.1",
14+
"@tensorflow/tfjs-backend-webgl": "^3.0.0-rc.1",
15+
"@tensorflow/tfjs-core": "^3.0.0-rc.1",
16+
"@tensorflow/tfjs-converter": "^3.0.0-rc.1",
1717
"stats.js": "^0.17.0"
1818
},
1919
"scripts": {
2020
"watch": "cross-env NODE_ENV=development parcel index.html --no-hmr --open",
2121
"build": "cross-env NODE_ENV=production parcel build index.html --public-url ./",
22+
"build-deps": "yarn build-model && yarn build",
23+
"build-model": "cd .. && yarn && yarn build-npm",
2224
"lint": "eslint .",
2325
"link-local": "yalc link @tensorflow-models/coco-ssd"
2426
},

coco-ssd/demo/yarn.lock

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -742,46 +742,44 @@
742742
"@parcel/utils" "^1.11.0"
743743
physical-cpu-count "^2.0.0"
744744

745-
"@tensorflow-models/[email protected]":
746-
version "2.0.2"
747-
resolved "https://registry.yarnpkg.com/@tensorflow-models/coco-ssd/-/coco-ssd-2.0.2.tgz#4fc546f880a72546c5eaf089e8c57f771a4bff62"
748-
integrity sha512-c7qoZ0VNL29nFXJyDRS6pGWK4AdxJRipie04Nwp6XGAiDaC0FK8QUHamlKOavE1xDDvHb1d5OQNkHGiCWzWLbQ==
745+
"@tensorflow-models/coco-ssd@link:../dist":
746+
version "0.0.0"
747+
uid ""
749748

750-
"@tensorflow/tfjs-backend-cpu@2.0.1":
751-
version "2.0.1"
752-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-2.0.1.tgz#959a5bbc7f956ff37c4fbced2db75cd299ce76c4"
753-
integrity sha512-ZTDdq+O6AgeOrkek42gmPWz2T0r8Y6dBGjEFWkCMLI/5v3KnkodUkHRQOUoIN5hiaPXnBp6425DpwT9CfxxJOg==
749+
"@tensorflow/tfjs-backend-cpu@3.0.0-rc.1", "@tensorflow/tfjs-backend-cpu@^3.0.0-rc.1":
750+
version "3.0.0-rc.1"
751+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-3.0.0-rc.1.tgz#b02e05706b2d91ab601e7eb397b6ea60ac0a9e2e"
752+
integrity sha512-9+13fs3vVpfOpDY+Aa/JXdda2SuBN/clxxoNYIX3pMY0GAGwpUaAkSECLuOOhnngHcl9pxuaJtgqrCcrq+A3/A==
754753
dependencies:
755754
"@types/seedrandom" "2.4.27"
756755
seedrandom "2.4.3"
757756

758-
"@tensorflow/tfjs-backend-webgl@2.0.1":
759-
version "2.0.1"
760-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-webgl/-/tfjs-backend-webgl-2.0.1.tgz#08eaff7fe9a7533b4d62475ec6220e843962af89"
761-
integrity sha512-Z0MNsbHyRBr2lHu4FKtmBgGGfmBOqB0zwN69d2uSEEvy/IsgtrGAwBVbB/Vv3hEK35RmgsaknKGergNugm23FQ==
757+
"@tensorflow/tfjs-backend-webgl@^3.0.0-rc.1":
758+
version "3.0.0-rc.1"
759+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-webgl/-/tfjs-backend-webgl-3.0.0-rc.1.tgz#21aacedcef687d2bb075c7951ac9e4f57faa79e6"
760+
integrity sha512-qEjtL/71HflBHJgWXhtj+8BVYB9Q+NHw282QGWi9QLA9SlWe3BRJhbGCaD28/Ddl+mSzBWFQnK+sKdZ04LL1Sg==
762761
dependencies:
763-
"@tensorflow/tfjs-backend-cpu" "2.0.1"
762+
"@tensorflow/tfjs-backend-cpu" "3.0.0-rc.1"
764763
"@types/offscreencanvas" "~2019.3.0"
765764
"@types/seedrandom" "2.4.27"
766765
"@types/webgl-ext" "0.0.30"
767-
"@types/webgl2" "0.0.4"
766+
"@types/webgl2" "0.0.5"
768767
seedrandom "2.4.3"
769768

770-
"@tensorflow/tfjs-converter@2.0.1":
771-
version "2.0.1"
772-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-2.0.1.tgz#0696455e6b6ed14e6f5f9cd937f8f2015a16569f"
773-
integrity sha512-AI4oUZ3Tv8l7fXeuLNJ3/vIp8shMo/VmtBlhIJye8i5FwMqSlZf984q3Jk6ES4lOxUdkmDehILf7uVNQX2Yb/w==
769+
"@tensorflow/tfjs-converter@^3.0.0-rc.1":
770+
version "3.0.0-rc.1"
771+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-3.0.0-rc.1.tgz#a15eb72ade80f7ae0e6403020763be0c5af6f2f7"
772+
integrity sha512-vVezwsDtrqM9CGDU+9c1WvPbLB5Odi9uiyEUHZEXMgNnPZ9Ix8a7RFOL7Y+8uBsI3B5wmLrWJuUNeyxUjA7yiA==
774773

775-
"@tensorflow/tfjs-core@2.0.1":
776-
version "2.0.1"
777-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-2.0.1.tgz#c64928423028e9e1821f7205367b1ff1f57ae3af"
778-
integrity sha512-LCmEXeGFgR3ai+ywGDYBqt4aCOSzEBlVKEflF1gAT22YcQuYh+/X4f58jY3yXfC+cn/FfIJFc2uj8b+D0MNWLQ==
774+
"@tensorflow/tfjs-core@^3.0.0-rc.1":
775+
version "3.0.0-rc.1"
776+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-3.0.0-rc.1.tgz#0b5316871eef2a4c8aa149d154e6ea6bbc7b631e"
777+
integrity sha512-h9a0TyWNJFqgmyfSklwI2q0SC93WFr8FBHwHorvsfm2mDK0ZrSs6bhWqa44tWRJjCrJNRq9J4GoTZQM292RTwg==
779778
dependencies:
780779
"@types/offscreencanvas" "~2019.3.0"
781780
"@types/seedrandom" "2.4.27"
782781
"@types/webgl-ext" "0.0.30"
783-
"@types/webgl2" "0.0.4"
784-
node-fetch "~2.1.2"
782+
node-fetch "~2.6.1"
785783
seedrandom "2.4.3"
786784

787785
"@types/offscreencanvas@~2019.3.0":
@@ -804,10 +802,10 @@
804802
resolved "https://registry.yarnpkg.com/@types/webgl-ext/-/webgl-ext-0.0.30.tgz#0ce498c16a41a23d15289e0b844d945b25f0fb9d"
805803
integrity sha512-LKVgNmBxN0BbljJrVUwkxwRYqzsAEPcZOe6S2T6ZaBDIrFp0qu4FNlpc5sM1tGbXUYFgdVQIoeLk1Y1UoblyEg==
806804

807-
"@types/[email protected].4":
808-
version "0.0.4"
809-
resolved "https://registry.yarnpkg.com/@types/webgl2/-/webgl2-0.0.4.tgz#c3b0f9d6b465c66138e84e64cb3bdf8373c2c279"
810-
integrity sha512-PACt1xdErJbMUOUweSrbVM7gSIYm1vTncW2hF6Os/EeWi6TXYAYMPp+8v6rzHmypE5gHrxaxZNXgMkJVIdZpHw==
805+
"@types/[email protected].5":
806+
version "0.0.5"
807+
resolved "https://registry.yarnpkg.com/@types/webgl2/-/webgl2-0.0.5.tgz#dd925e20ab8ace80eb4b1e46fda5b109c508fb0d"
808+
integrity sha512-oGaKsBbxQOY5+aJFV3KECDhGaXt+yZJt2y/OZsnQGLRkH6Fvr7rv4pCt3SRH1somIHfej/c4u7NSpCyd9x+1Ow==
811809

812810
abab@^2.0.0:
813811
version "2.0.2"
@@ -4318,10 +4316,10 @@ node-addon-api@^1.6.0:
43184316
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-1.7.1.tgz#cf813cd69bb8d9100f6bdca6755fc268f54ac492"
43194317
integrity sha512-2+DuKodWvwRTrCfKOeR24KIc5unKjOh8mz17NCzVnHWfjAdDqbfbjqh7gUT+BkXBRQM52+xCHciKWonJ3CbJMQ==
43204318

4321-
node-fetch@~2.1.2:
4322-
version "2.1.2"
4323-
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.1.2.tgz#ab884e8e7e57e38a944753cec706f788d1768bb5"
4324-
integrity sha1-q4hOjn5X44qUR1POxwb3iNF2i7U=
4319+
node-fetch@~2.6.1:
4320+
version "2.6.1"
4321+
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
4322+
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
43254323

43264324
node-forge@^0.7.1:
43274325
version "0.7.6"

coco-ssd/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
"url": "https://github.com/tensorflow/tfjs-models.git"
1414
},
1515
"peerDependencies": {
16-
"@tensorflow/tfjs-converter": "^2.0.1",
17-
"@tensorflow/tfjs-core": "^2.0.1"
16+
"@tensorflow/tfjs-converter": "^3.0.0-rc.1",
17+
"@tensorflow/tfjs-core": "^3.0.0-rc.1"
1818
},
1919
"devDependencies": {
2020
"@rollup/plugin-commonjs": "^11.0.2",
2121
"@rollup/plugin-node-resolve": "^7.1.1",
2222
"@rollup/plugin-typescript": "^3.0.0",
23-
"@tensorflow/tfjs-backend-cpu": "^2.0.1",
24-
"@tensorflow/tfjs-converter": "^2.0.1",
25-
"@tensorflow/tfjs-core": "^2.0.1",
23+
"@tensorflow/tfjs-backend-cpu": "^3.0.0-rc.1",
24+
"@tensorflow/tfjs-converter": "^3.0.0-rc.1",
25+
"@tensorflow/tfjs-core": "^3.0.0-rc.1",
2626
"@types/jasmine": "~2.8.8",
2727
"babel-core": "~6.26.0",
2828
"babel-plugin-transform-runtime": "~6.23.0",
@@ -43,4 +43,4 @@
4343
"test": "ts-node --skip-ignore --project tsconfig.test.json run_tests.ts"
4444
},
4545
"license": "Apache-2.0"
46-
}
46+
}

coco-ssd/src/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,13 @@ export class ObjectDetection {
108108
private async infer(
109109
img: tf.Tensor3D|ImageData|HTMLImageElement|HTMLCanvasElement|
110110
HTMLVideoElement,
111-
maxNumBoxes: number,
112-
minScore: number): Promise<DetectedObject[]> {
111+
maxNumBoxes: number, minScore: number): Promise<DetectedObject[]> {
113112
const batched = tf.tidy(() => {
114113
if (!(img instanceof tf.Tensor)) {
115114
img = tf.browser.fromPixels(img);
116115
}
117116
// Reshape to a single-element batch so we can pass it to executeAsync.
118-
return img.expandDims(0);
117+
return tf.expandDims(img);
119118
});
120119
const height = batched.shape[1];
121120
const width = batched.shape[2];
@@ -223,8 +222,7 @@ export class ObjectDetection {
223222
async detect(
224223
img: tf.Tensor3D|ImageData|HTMLImageElement|HTMLCanvasElement|
225224
HTMLVideoElement,
226-
maxNumBoxes = 20,
227-
minScore = 0.5): Promise<DetectedObject[]> {
225+
maxNumBoxes = 20, minScore = 0.5): Promise<DetectedObject[]> {
228226
return this.infer(img, maxNumBoxes, minScore);
229227
}
230228

coco-ssd/yarn.lock

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -88,29 +88,28 @@
8888
estree-walker "^1.0.1"
8989
picomatch "^2.2.2"
9090

91-
"@tensorflow/tfjs-backend-cpu@^2.0.1":
92-
version "2.0.1"
93-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-2.0.1.tgz#959a5bbc7f956ff37c4fbced2db75cd299ce76c4"
94-
integrity sha512-ZTDdq+O6AgeOrkek42gmPWz2T0r8Y6dBGjEFWkCMLI/5v3KnkodUkHRQOUoIN5hiaPXnBp6425DpwT9CfxxJOg==
91+
"@tensorflow/tfjs-backend-cpu@^3.0.0-rc.1":
92+
version "3.0.0-rc.1"
93+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-3.0.0-rc.1.tgz#b02e05706b2d91ab601e7eb397b6ea60ac0a9e2e"
94+
integrity sha512-9+13fs3vVpfOpDY+Aa/JXdda2SuBN/clxxoNYIX3pMY0GAGwpUaAkSECLuOOhnngHcl9pxuaJtgqrCcrq+A3/A==
9595
dependencies:
9696
"@types/seedrandom" "2.4.27"
9797
seedrandom "2.4.3"
9898

99-
"@tensorflow/tfjs-converter@^2.0.1":
100-
version "2.0.1"
101-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-2.0.1.tgz#0696455e6b6ed14e6f5f9cd937f8f2015a16569f"
102-
integrity sha512-AI4oUZ3Tv8l7fXeuLNJ3/vIp8shMo/VmtBlhIJye8i5FwMqSlZf984q3Jk6ES4lOxUdkmDehILf7uVNQX2Yb/w==
99+
"@tensorflow/tfjs-converter@^3.0.0-rc.1":
100+
version "3.0.0-rc.1"
101+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-3.0.0-rc.1.tgz#a15eb72ade80f7ae0e6403020763be0c5af6f2f7"
102+
integrity sha512-vVezwsDtrqM9CGDU+9c1WvPbLB5Odi9uiyEUHZEXMgNnPZ9Ix8a7RFOL7Y+8uBsI3B5wmLrWJuUNeyxUjA7yiA==
103103

104-
"@tensorflow/tfjs-core@^2.0.1":
105-
version "2.0.1"
106-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-2.0.1.tgz#c64928423028e9e1821f7205367b1ff1f57ae3af"
107-
integrity sha512-LCmEXeGFgR3ai+ywGDYBqt4aCOSzEBlVKEflF1gAT22YcQuYh+/X4f58jY3yXfC+cn/FfIJFc2uj8b+D0MNWLQ==
104+
"@tensorflow/tfjs-core@^3.0.0-rc.1":
105+
version "3.0.0-rc.1"
106+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-3.0.0-rc.1.tgz#0b5316871eef2a4c8aa149d154e6ea6bbc7b631e"
107+
integrity sha512-h9a0TyWNJFqgmyfSklwI2q0SC93WFr8FBHwHorvsfm2mDK0ZrSs6bhWqa44tWRJjCrJNRq9J4GoTZQM292RTwg==
108108
dependencies:
109109
"@types/offscreencanvas" "~2019.3.0"
110110
"@types/seedrandom" "2.4.27"
111111
"@types/webgl-ext" "0.0.30"
112-
"@types/webgl2" "0.0.4"
113-
node-fetch "~2.1.2"
112+
node-fetch "~2.6.1"
114113
seedrandom "2.4.3"
115114

116115
"@types/color-name@^1.1.1":
@@ -160,11 +159,6 @@
160159
resolved "https://registry.yarnpkg.com/@types/webgl-ext/-/webgl-ext-0.0.30.tgz#0ce498c16a41a23d15289e0b844d945b25f0fb9d"
161160
integrity sha512-LKVgNmBxN0BbljJrVUwkxwRYqzsAEPcZOe6S2T6ZaBDIrFp0qu4FNlpc5sM1tGbXUYFgdVQIoeLk1Y1UoblyEg==
162161

163-
164-
version "0.0.4"
165-
resolved "https://registry.yarnpkg.com/@types/webgl2/-/webgl2-0.0.4.tgz#c3b0f9d6b465c66138e84e64cb3bdf8373c2c279"
166-
integrity sha512-PACt1xdErJbMUOUweSrbVM7gSIYm1vTncW2hF6Os/EeWi6TXYAYMPp+8v6rzHmypE5gHrxaxZNXgMkJVIdZpHw==
167-
168162
ansi-regex@^2.0.0:
169163
version "2.1.1"
170164
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
@@ -938,10 +932,10 @@ nanoid@^2.1.6:
938932
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.1.11.tgz#ec24b8a758d591561531b4176a01e3ab4f0f0280"
939933
integrity sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA==
940934

941-
node-fetch@~2.1.2:
942-
version "2.1.2"
943-
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.1.2.tgz#ab884e8e7e57e38a944753cec706f788d1768bb5"
944-
integrity sha1-q4hOjn5X44qUR1POxwb3iNF2i7U=
935+
node-fetch@~2.6.1:
936+
version "2.6.1"
937+
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
938+
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
945939

946940
normalize-package-data@^2.3.2:
947941
version "2.5.0"

0 commit comments

Comments
 (0)