Skip to content

Commit

Permalink
Update models to use latest 0.x (tensorflow#156)
Browse files Browse the repository at this point in the history
Update the models to use the latest `0.x`.

Fixes tensorflow/tfjs#1282
Fixes tensorflow/tfjs#1283

- Update each model to depend on tfjs `0.15.3`
- Remove all deprecated API (fromPixels, tensor.get(), loadModel, loadFrozenModel, data.forEachAsync)
- Remove private API imports such as from 'tfjs_core/dist/....'
- Migrate all models hosted on GCP to use the new model.json format
  - `ssd_mobilenet_v1`, `ssd_mobilenet_v2/`, `ssdlite_mobilenet_v2/`, `mobilenet_v1_1.0_224`, `mobilenet_v2_1.0_224`, `posenet_mobilenet_{025,050,075,100}_partmap`, `universal_sentence_encoder`, `toxicity`


- Align the lint and yarn commands across the models
- Tested that each model's demo is working by yalc linking the model's npm package `@master`.

INTERNAL
  • Loading branch information
dsmilkov authored Feb 26, 2019
1 parent a09bcb3 commit 707c360
Show file tree
Hide file tree
Showing 58 changed files with 2,555 additions and 652 deletions.
9 changes: 2 additions & 7 deletions body-pix/demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ yarn watch

## If you are developing body-pix locally, and want to test the changes in the demos

Install yalc:
```sh
npm i -g yalc
```

cd into the body-pix folder:
Cd into the body-pix folder:
```sh
cd body-pix
```
Expand All @@ -55,7 +50,7 @@ yarn

Link the local body-pix to the demos:
```sh
yalc link @tensorflow-models/body-pix
yarn yalc link @tensorflow-models/body-pix
```

Start the dev demo server:
Expand Down
2 changes: 1 addition & 1 deletion body-pix/demos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"@tensorflow-models/body-pix": "0.1.1",
"@tensorflow/tfjs": "0.15.1",
"@tensorflow/tfjs": "0.15.3",
"stats.js": "0.17.0"
},
"scripts": {
Expand Down
54 changes: 24 additions & 30 deletions body-pix/demos/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -700,48 +700,47 @@
resolved "https://registry.yarnpkg.com/@tensorflow-models/body-pix/-/body-pix-0.1.1.tgz#35c111684c639adc936c61dc3d785b6b29dc4f32"
integrity sha512-pdbzyDjDJCwdE95MiZ7hAsBSpVlNmDbeHNWygEwv4pozcVG8nA/a9r2jlD6k2Vx57ne0DA+q0ifvrQ9+sVqTVA==

"@tensorflow/[email protected].1":
version "0.8.1"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-0.8.1.tgz#baecc2dd20e5fca81391df1c6f11a7e865c71ce9"
integrity sha512-tdUq5N6y+L9XUM6c9poAP9GAAkzh9XEtP/mD96nFxllpNeDODSmDkdZKFzoAkmXwubojcUSJ1wbVYqCFbgaCOg==
"@tensorflow/[email protected].4":
version "0.8.4"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-0.8.4.tgz#7c1326e9858c6c3a6d23947e31a73e9458450a9b"
integrity sha512-hHTyQiQOeYvFB/zL/jDT51hx+voOoKOVHSAWzPG10G8+H7ljQsRzxj19X/PIk8EUo9TXJT2Aj+/WW0guK+0wJg==
dependencies:
"@types/long" "~3.0.32"
js-base64 "2.4.9"
protobufjs "~6.8.6"

"@tensorflow/[email protected].1":
version "0.15.1"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-0.15.1.tgz#6196d2a9630236c77d71e036f05d2d6eadc2a25a"
integrity sha512-csZ1GvRiwy0PJcJXz6Xt9W+ZZHf0JI+nyJPtJU4QSVJVIFRCCAWqn2SsYwNt2Bp2rw2ZHhfuStz3veFUgaDSMA==
"@tensorflow/[email protected].4":
version "0.15.4"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-0.15.4.tgz#aaf52acd209476ebde7bd9a37a7c60ec9d067b65"
integrity sha512-CWi6PuWOBfFRRzn4gl4rcCtwHkimYexGaQi5rwF2jPntknT8TIhonkacvuBROEfeq2PEvqKzCWJTU5+AmCj2HQ==
dependencies:
"@types/seedrandom" "2.4.27"
"@types/webgl-ext" "0.0.30"
"@types/webgl2" "0.0.4"
seedrandom "2.4.3"

"@tensorflow/[email protected].1":
version "0.2.1"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-data/-/tfjs-data-0.2.1.tgz#6a4b2e08ef472b6f1a533b07c59aff71c2f4d03f"
integrity sha512-A8YSCtPkaXXQeJwI7CUw/Y+vCoCxiCRIH4Z0DOTD16dl9Iz4S+sr8VA3I4HsLLgS9BNXbRWFQxnbCe/j1ATtuA==
"@tensorflow/[email protected].3":
version "0.2.3"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-data/-/tfjs-data-0.2.3.tgz#67c0cd505485c9b0b6a83cb1c8a24559c5adfa68"
integrity sha512-U9eDD35i0jFQtbm90XMP+dVEwaE0hCrhbt6OEpDCTYxdCLOMDnKVmx+q2TOoCPvTxToC6jHOMPKXO23bLAJsxw==
dependencies:
"@types/node-fetch" "^2.1.2"
node-fetch "~2.1.2"
seedrandom "~2.4.3"

"@tensorflow/[email protected].1":
version "0.10.1"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-layers/-/tfjs-layers-0.10.1.tgz#b7019302b776c7281fde425043659b6e97403dfb"
integrity sha512-p8b6mynBR/owKCRKR7J0tu7Qherlyzsm5MkgfVk9Z1PCqsR79soYEf1VbPsRap5g09Xl8RZgB5S/aMkRHy18Qg==
"@tensorflow/[email protected].3":
version "0.10.3"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-layers/-/tfjs-layers-0.10.3.tgz#cf4001b5b7566b1526e65e615439e85070a1012c"
integrity sha512-Xhaz4+ZuL2SEm3S0u4x04dMYMrcG4w4dhMOjoQW8GhAJU4p7LkmP9TmwMEHp7CIVJiJzzQy7Hg8E5fESEnJinA==

"@tensorflow/[email protected].1":
version "0.15.1"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs/-/tfjs-0.15.1.tgz#ed3ae264159eb60e63be38edb83fdb6cd03db2d2"
integrity sha512-PV+Heq+YrGp14e3+brYcC7SZVtq7wsrxyJe6YQIwySMcGBipP2i6UCWJMgbq8W71MMGBrST+dSBUkM1QZkZpHw==
"@tensorflow/[email protected].3":
version "0.15.3"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs/-/tfjs-0.15.3.tgz#6608833952858c8984f20962eb86624f99196f06"
integrity sha512-NBAs+iGBNBxprm98mk488EfTDl2kA/lzNguoQGEMeIPWVHTbadSn2QV5xXKAf/fcOat+JwVfqe2vxHBbTjHMOw==
dependencies:
"@tensorflow/tfjs-converter" "0.8.1"
"@tensorflow/tfjs-core" "0.15.1"
"@tensorflow/tfjs-data" "0.2.1"
"@tensorflow/tfjs-layers" "0.10.1"
"@tensorflow/tfjs-converter" "0.8.4"
"@tensorflow/tfjs-core" "0.15.4"
"@tensorflow/tfjs-data" "0.2.3"
"@tensorflow/tfjs-layers" "0.10.3"

"@types/long@^4.0.0":
version "4.0.0"
Expand Down Expand Up @@ -3781,11 +3780,6 @@ isobject@^3.0.0, isobject@^3.0.1:
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=

[email protected]:
version "2.4.9"
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.4.9.tgz#748911fb04f48a60c4771b375cac45a80df11c03"
integrity sha512-xcinL3AuDJk7VSzsHgb9DvvIXayBbadtMZ4HFPx8rUszbW1MuNMlwYVC4zzCZ6e1sqZpnNS5ZFYOhXqA39T7LQ==

js-base64@^2.1.9:
version "2.4.5"
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.4.5.tgz#e293cd3c7c82f070d700fc7a1ca0a2e69f101f92"
Expand Down
9 changes: 5 additions & 4 deletions body-pix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"url": "https://github.com/tensorflow/tfjs-models.git"
},
"peerDependencies": {
"@tensorflow/tfjs": "^0.15.1"
"@tensorflow/tfjs": "^0.15.3"
},
"devDependencies": {
"@tensorflow/tfjs": "^0.15.1",
"@tensorflow/tfjs": "^0.15.3",
"@types/jasmine": "~2.5.53",
"jasmine": "~3.2.0",
"jasmine-core": "~3.1.0",
Expand All @@ -27,11 +27,12 @@
"rollup-plugin-uglify": "~3.0.0",
"ts-node": "~5.0.0",
"tslint": "~5.8.0",
"typescript": "2.9.2"
"typescript": "2.9.2",
"yalc": "^1.0.0-pre.27"
},
"scripts": {
"build": "rimraf dist && tsc",
"publish-local": "yarn build && rollup -c && yalc push",
"publish-local": "yarn build && rollup -c && yalc publish",
"test": "ts-node run_tests.ts",
"publish-npm": "yarn build && rollup -c && npm publish",
"lint": "tslint -p . -t verbose"
Expand Down
5 changes: 2 additions & 3 deletions body-pix/src/body_pix_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,8 @@ export const mobilenetLoader = {

const baseUrl = checkpoint.url;

const model = await tf.loadFrozenModel(
`${baseUrl}tensorflowjs_model.pb`,
`${baseUrl}weights_manifest.json`) as tf.FrozenModel;
const model =
await tf.loadGraphModel(`${baseUrl}model.json`) as tf.GraphModel;

const weights = new ModelWeights(model);

Expand Down
10 changes: 5 additions & 5 deletions body-pix/src/model_weights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import * as tf from '@tensorflow/tfjs';

export class ModelWeights {
private frozenModel: tf.FrozenModel;
private graphModel: tf.GraphModel;

constructor(frozenModel: tf.FrozenModel) {
this.frozenModel = frozenModel;
constructor(graphModel: tf.GraphModel) {
this.graphModel = graphModel;
}

weights(layerName: string) {
Expand All @@ -44,10 +44,10 @@ export class ModelWeights {
}

private getVariable(name: string) {
return this.frozenModel.weights[`${name}`][0];
return this.graphModel.weights[`${name}`][0];
}

dispose() {
this.frozenModel.dispose();
this.graphModel.dispose();
}
}
Loading

0 comments on commit 707c360

Please sign in to comment.