Skip to content

Commit

Permalink
update peer deps for toxicity model and increase the minor version (t…
Browse files Browse the repository at this point in the history
…ensorflow#243)

* update deps for toxicity model

* update dep filter
  • Loading branch information
pyu10055 authored Jun 19, 2019
1 parent 6d16029 commit 389f23a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 53 deletions.
4 changes: 2 additions & 2 deletions toxicity/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"node": ">=8.9.0"
},
"dependencies": {
"@tensorflow-models/toxicity": "^1.0.2",
"@tensorflow/tfjs": "^1.1.0"
"@tensorflow-models/toxicity": "1.1.0",
"@tensorflow/tfjs": "^1.2.1"
},
"scripts": {
"watch": "cross-env NODE_ENV=development parcel index.html --no-hmr --open ",
Expand Down
12 changes: 7 additions & 5 deletions toxicity/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tensorflow-models/toxicity",
"version": "1.0.3",
"version": "1.1.0",
"description": "Toxicity model in TensorFlow.js",
"main": "dist/index.js",
"jsnext:main": "dist/toxicity.esm.js",
Expand All @@ -13,13 +13,15 @@
"url": "https://github.com/tensorflow/tfjs-models.git"
},
"peerDependencies": {
"@tensorflow/tfjs": "^1.1.0"
"@tensorflow/tfjs-core": "~1.2.1",
"@tensorflow/tfjs-converter": "~1.2.1"
},
"dependencies": {
"@tensorflow-models/universal-sentence-encoder": "^1.0.3"
"@tensorflow-models/universal-sentence-encoder": "~1.1.0"
},
"devDependencies": {
"@tensorflow/tfjs": "^1.1.0",
"@tensorflow/tfjs-core": "~1.2.1",
"@tensorflow/tfjs-converter": "~1.2.1",
"@types/jasmine": "~2.5.53",
"babel-core": "^6.26.3",
"jasmine": "^3.3.1",
Expand All @@ -42,4 +44,4 @@
"lint": "tslint -p . -t verbose"
},
"license": "Apache-2.0"
}
}
10 changes: 6 additions & 4 deletions toxicity/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
*/

import * as use from '@tensorflow-models/universal-sentence-encoder';
import * as tf from '@tensorflow/tfjs';
import * as tfconv from '@tensorflow/tfjs-converter';
import * as tf from '@tensorflow/tfjs-core';

// import {padInput} from './util';

Expand All @@ -41,7 +42,7 @@ export async function load(threshold: number, toxicityLabels: string[]) {

export class ToxicityClassifier {
private tokenizer: use.Tokenizer;
private model: tf.GraphModel;
private model: tfconv.GraphModel;
private labels: string[];
private threshold: number;
private toxicityLabels: string[];
Expand All @@ -52,7 +53,7 @@ export class ToxicityClassifier {
}

async loadModel() {
return tf.loadGraphModel(`${BASE_PATH}model.json`);
return tfconv.loadGraphModel(`${BASE_PATH}model.json`);
}

async loadTokenizer() {
Expand All @@ -74,7 +75,8 @@ export class ToxicityClassifier {
} else {
tf.util.assert(
this.toxicityLabels.every(d => this.labels.indexOf(d) > -1),
() => `toxicityLabels argument must contain only items from the model ` +
() =>
`toxicityLabels argument must contain only items from the model ` +
`heads ${this.labels.join(', ')}, ` +
`got ${this.toxicityLabels.join(', ')}`);
}
Expand Down
54 changes: 12 additions & 42 deletions toxicity/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
# yarn lockfile v1


"@tensorflow-models/universal-sentence-encoder@^1.0.3":
version "1.0.3"
resolved "https://registry.yarnpkg.com/@tensorflow-models/universal-sentence-encoder/-/universal-sentence-encoder-1.0.3.tgz#40e6fe8b167837479107414b7dfdff197c25f043"
integrity sha512-x0abY4U1bzZUfPYID45UMe1Wt0y+kGE7aOloKQE7FtnORZErZX8qWTdpjUDJBJWTwGYACxUSlJHC/DmR8p/ZNw==

"@tensorflow/[email protected]":
"@tensorflow-models/universal-sentence-encoder@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-1.1.0.tgz#1d6f58347e9b3826c02090e06e6590b0c4df2d4e"
integrity sha512-gUkoRoYm9yrVVQNp8nD+pEWOPUNhayCSrUHNItSfIm8Lzbgx6brVxVdz5T8V0kT0yh67Pp9Er/LIlf54p7KikA==
resolved "https://registry.yarnpkg.com/@tensorflow-models/universal-sentence-encoder/-/universal-sentence-encoder-1.1.0.tgz#6ecf6a1bd9fb43691a5d7ce5030dc3018dce6361"
integrity sha512-SaA3ITiVrcBwoZHK28Fv1sR2m6pxTh3kWqokKTqdw7oqNvE/K0Kf2TSwI8qsliQn3FSuV2zYMf0lhT+mNNV+sw==

"@tensorflow/[email protected]":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-1.1.0.tgz#028c69291e19c328c4c30e18d29b09135c22cb44"
integrity sha512-loPpHGVjiyEb+Ixlsj8prQ/r4exekITn7vM4WEyHUouFKx0/CuoB2FQ0m6DSb/6ApvucxTWGGNTRRo4HK4Ma0Q==
"@tensorflow/tfjs-converter@~1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-1.2.1.tgz#996e9e2e7d0f03717e7fc1211176ee43049b38ac"
integrity sha512-HKWlGV9uSWMUaogo6TyS/x2xdgO/du/vXPj91iGnm+t44Jl++1PXYD0LKD1LdNLR2RhUS3TJv6HuqDmYOO8EYw==

"@tensorflow/tfjs-core@~1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-1.2.1.tgz#0ff54aa7fd412b8c17e39f6ec5a97bf032e8f530"
integrity sha512-cpSHl+tP7cketq0cAyJPbIGxNlPV7mR6lkMLLDvZAmZUTBSyBufCdJg/KwgjHMZksE/KqjL4/RyccOGBAQcb7g==
dependencies:
"@types/seedrandom" "2.4.27"
"@types/webgl-ext" "0.0.30"
Expand All @@ -25,29 +25,6 @@
optionalDependencies:
rollup-plugin-visualizer "~1.1.1"

"@tensorflow/[email protected]":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-data/-/tfjs-data-1.1.0.tgz#8d9a0175497930061532c8d43b419b25b26b9bbf"
integrity sha512-0+PfAsaZs/pmaxiLunb4c1rPRdu47+CYe5kxpu2P8Xn3k+vhlBYMu+zsVgs5RrTRFLWVzVeH9muA1SJLkMGZPA==
dependencies:
"@types/node-fetch" "^2.1.2"
node-fetch "~2.1.2"

"@tensorflow/[email protected]":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-layers/-/tfjs-layers-1.1.0.tgz#fd221c254d2fca13e93e83669bdde3140e7a0434"
integrity sha512-a0gXjOWvGi9gc2q8/gK79zfD5WqEZnAhZfpm6b7AoKXjDUBq4GgdbbWCfv2nYBlmMoXgRSRSV44UmJVExep0uw==

"@tensorflow/tfjs@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs/-/tfjs-1.1.0.tgz#77809dc336655a7ff0bbf76527cc3d7b9e68e330"
integrity sha512-CxcFzl2KtknO3f12xuuv8kq8usMA7xGWpJajubIlYBp4KoBDhiDimP/DwBlTvFZq5RT5riHGtA4BWjMj6rnDcw==
dependencies:
"@tensorflow/tfjs-converter" "1.1.0"
"@tensorflow/tfjs-core" "1.1.0"
"@tensorflow/tfjs-data" "1.1.0"
"@tensorflow/tfjs-layers" "1.1.0"

"@types/[email protected]":
version "0.0.38"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.38.tgz#c1be40aa933723c608820a99a373a16d215a1ca2"
Expand All @@ -58,13 +35,6 @@
resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.5.54.tgz#a6b5f2ae2afb6e0307774e8c7c608e037d491c63"
integrity sha512-B9YofFbUljs19g5gBKUYeLIulsh31U5AK70F41BImQRHEZQGm4GcN922UvnYwkduMqbC/NH+9fruWa/zrqvHIg==

"@types/node-fetch@^2.1.2":
version "2.3.2"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.3.2.tgz#e01893b176c6fa1367743726380d65bce5d6576b"
integrity sha512-yW0EOebSsQme9yKu09XbdDfle4/SmWZMK4dfteWcSLCYNQQcF+YOv0kIrvm+9pO11/ghA4E6A+RNQqvYj4Nr3A==
dependencies:
"@types/node" "*"

"@types/node@*":
version "11.13.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-11.13.6.tgz#37ec75690830acb0d74ce3c6c43caab787081e85"
Expand Down

0 comments on commit 389f23a

Please sign in to comment.