Skip to content

Commit f3f34bd

Browse files
committed
updates for new tfjs version
1 parent 863b1a7 commit f3f34bd

File tree

4 files changed

+33
-133
lines changed

4 files changed

+33
-133
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"keywords": [],
66
"main": "src/index.js",
77
"dependencies": {
8-
"@tensorflow-models/coco-ssd": "0.1.1",
9-
"@tensorflow/tfjs": "0.14.0",
8+
"@tensorflow/tfjs": "1.0.0",
109
"react": "16.5.2",
1110
"react-dom": "16.5.2",
1211
"react-magic-dropzone": "1.0.1",

src/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import ReactDOM from 'react-dom'
44
import * as tf from '@tensorflow/tfjs'
55
import './styles.css'
66

7-
const LABELS_URL = process.env.PUBLIC_URL + '/model_web/labels.json'
8-
const MODEL_URL = process.env.PUBLIC_URL + '/model_web/tensorflowjs_model.pb'
9-
const WEIGHTS_URL = process.env.PUBLIC_URL + '/model_web/weights_manifest.json'
7+
const MODEL_URL = process.env.PUBLIC_URL + '/model_web/'
8+
const LABELS_URL = MODEL_URL + 'labels.json'
9+
const MODEL_JSON = MODEL_URL + 'model.json'
1010

1111
const TFWrapper = model => {
1212
const calculateMaxScores = (scores, numBoxes, numClasses) => {
@@ -61,7 +61,7 @@ const TFWrapper = model => {
6161

6262
const detect = input => {
6363
const batched = tf.tidy(() => {
64-
const img = tf.fromPixels(input)
64+
const img = tf.browser.fromPixels(input)
6565
// Reshape to a single-element batch so we can pass it to executeAsync.
6666
return img.expandDims(0)
6767
})
@@ -141,7 +141,8 @@ class App extends React.Component {
141141
}
142142
})
143143
})
144-
const modelPromise = tf.loadFrozenModel(MODEL_URL, WEIGHTS_URL)
144+
145+
const modelPromise = tf.loadGraphModel(MODEL_JSON)
145146
const labelsPromise = fetch(LABELS_URL).then(data => data.json())
146147
Promise.all([modelPromise, labelsPromise, webCamPromise])
147148
.then(values => {

src/styles.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
position: fixed;
33
top: 0;
44
left: 0;
5+
/* transform: scaleX(-1); */
56
}

yarn.lock

Lines changed: 25 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -801,59 +801,6 @@
801801
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
802802
integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==
803803

804-
"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2":
805-
version "1.1.2"
806-
resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf"
807-
integrity sha1-m4sMxmPWaafY9vXQiToU00jzD78=
808-
809-
"@protobufjs/base64@^1.1.2":
810-
version "1.1.2"
811-
resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735"
812-
integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==
813-
814-
"@protobufjs/codegen@^2.0.4":
815-
version "2.0.4"
816-
resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb"
817-
integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==
818-
819-
"@protobufjs/eventemitter@^1.1.0":
820-
version "1.1.0"
821-
resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70"
822-
integrity sha1-NVy8mLr61ZePntCV85diHx0Ga3A=
823-
824-
"@protobufjs/fetch@^1.1.0":
825-
version "1.1.0"
826-
resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45"
827-
integrity sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=
828-
dependencies:
829-
"@protobufjs/aspromise" "^1.1.1"
830-
"@protobufjs/inquire" "^1.1.0"
831-
832-
"@protobufjs/float@^1.0.2":
833-
version "1.0.2"
834-
resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1"
835-
integrity sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=
836-
837-
"@protobufjs/inquire@^1.1.0":
838-
version "1.1.0"
839-
resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089"
840-
integrity sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=
841-
842-
"@protobufjs/path@^1.1.2":
843-
version "1.1.2"
844-
resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d"
845-
integrity sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=
846-
847-
"@protobufjs/pool@^1.1.0":
848-
version "1.1.0"
849-
resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54"
850-
integrity sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=
851-
852-
"@protobufjs/utf8@^1.1.0":
853-
version "1.1.0"
854-
resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570"
855-
integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=
856-
857804
"@svgr/core@^2.4.1":
858805
version "2.4.1"
859806
resolved "https://registry.yarnpkg.com/@svgr/core/-/core-2.4.1.tgz#03a407c28c4a1d84305ae95021e8eabfda8fa731"
@@ -879,63 +826,44 @@
879826
"@svgr/core" "^2.4.1"
880827
loader-utils "^1.1.0"
881828

882-
"@tensorflow-models/[email protected]":
883-
version "0.1.1"
884-
resolved "https://registry.yarnpkg.com/@tensorflow-models/coco-ssd/-/coco-ssd-0.1.1.tgz#e546d3cacd0c11e9c177c591e7e8ff0eb8fd150b"
885-
integrity sha512-b3OxP0hA9jKKKFnoi/etAdyHaf+dH1aiEpQSAZQf08/jVllp1I1ZhtLz1MTQhaT2hLk/nXZvSVkg18u+ciGBzg==
886-
887-
"@tensorflow/[email protected]":
888-
version "0.7.0"
889-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-0.7.0.tgz#a9766d0ccf2fa6ec45815ab2973a39ceb3d05667"
890-
integrity sha512-hdhaFnLKGI/GLTaAoW7zUMc4QJ5T1RxW9jT/0otgDfqwG/lZvSxqxRFULO6omTGs+w5mFzIGn5erm5/ZwZpbFg==
891-
dependencies:
892-
"@types/long" "~3.0.32"
893-
protobufjs "~6.8.6"
829+
"@tensorflow/[email protected]":
830+
version "1.0.0"
831+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-1.0.0.tgz#cdd7bbf9f39fde93156fb1bddeac16a8ab157d6d"
832+
integrity sha512-BGiR2U2BEKL+Gwf2Pqu7fZZw+z3ptMORTeS/rIxVnpIbeb7jsD7q25ibvfX1yuk21GM7igfZ53c4FPwqa24G9Q==
894833

895-
"@tensorflow/tfjs-core@0.14.0":
896-
version "0.14.0"
897-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-0.14.0.tgz#b279aac3829552a40e1894cd9b77c73416fe2b47"
898-
integrity sha512-XzsLQma506xCeM2NmIp+AcFtCPB4XE/VQ5ljJmMUCx0RxUWcmtJJ6FwvXsMMlS3TbHPImnxO5PwZ/5ZTgktgdg==
834+
"@tensorflow/tfjs-core@1.0.0":
835+
version "1.0.0"
836+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-1.0.0.tgz#1be6240efc5b2f270f90a032713dfac666fa1533"
837+
integrity sha512-YiGjDJODPXI9S9AEizf6rdkYFFFCBCqwOmFqBY2MderPaDJ71rqhTzWQkWCMXV4Jhz5J+TEqtr8ishl3Zyid6A==
899838
dependencies:
900839
"@types/seedrandom" "2.4.27"
901840
"@types/webgl-ext" "0.0.30"
902841
"@types/webgl2" "0.0.4"
903842
seedrandom "2.4.3"
904843

905-
"@tensorflow/tfjs-data@0.1.2":
906-
version "0.1.2"
907-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-data/-/tfjs-data-0.1.2.tgz#01bd29e2467457819c1a276c5a493e08a7a4e69d"
908-
integrity sha512-AcCir2RUKIfNkmJN55LOHwHAgeYGBkRBf3c7wAFo1J270d9SxVi9s3kHvtQK4H4SDiDW5VXQohIbuk1Cb2EmsQ==
844+
"@tensorflow/tfjs-data@1.0.0":
845+
version "1.0.0"
846+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-data/-/tfjs-data-1.0.0.tgz#ccdc4fe713ca903cdc61135f7c361effaea4e670"
847+
integrity sha512-pWn0OH5x67Qa98FWiBO1UvcglEsDFf57Tv7amtC+WxlMrH5hUHSaR30dBaW1qpdOEJkDRJtUg6tNTG2av6mqVQ==
909848
dependencies:
910849
"@types/node-fetch" "^2.1.2"
911850
node-fetch "~2.1.2"
912851
seedrandom "~2.4.3"
913-
utf8 "~2.1.2"
914852

915-
"@tensorflow/tfjs-layers@0.9.0":
916-
version "0.9.0"
917-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-layers/-/tfjs-layers-0.9.0.tgz#2d9f8cfd36b7d6c694e11cd93e0a178ff96afa2b"
918-
integrity sha512-HfwEwddSRKa/Q846joHsS32HD009z0cYZzBtARG6iiYVEKQBixPtcGhdjuLg4ZoI0id/etpds2Kg+jT/f1p5sQ==
853+
"@tensorflow/tfjs-layers@1.0.0":
854+
version "1.0.0"
855+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-layers/-/tfjs-layers-1.0.0.tgz#e4344e9221001850eb1615184fa5ca2499f75254"
856+
integrity sha512-+RB5TKM/L7qLn17ic8da/G2qg8EFhRvZIoRA6uCCs5OMUJAUQqhDqBNaoWiy0pYtXDzfZJu3ZOkDbAg2Xv2YOQ==
919857

920-
"@tensorflow/tfjs@0.14.0":
921-
version "0.14.0"
922-
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs/-/tfjs-0.14.0.tgz#77d3a2f692a349b7adf0c4b00af221135cc682ad"
923-
integrity sha512-L6ieTnEJUrD/bgqN1nukh+ywlhrtti1a/eFcTRo+9zWc6csiblPfKbEEJHBTWg4JmEpiuzu6be0Gl4wSDxiLJw==
858+
"@tensorflow/tfjs@1.0.0":
859+
version "1.0.0"
860+
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs/-/tfjs-1.0.0.tgz#a4a181c59e1b82ad8b09b5d1da5cafc9a457b83a"
861+
integrity sha512-ZnX4GvIpKBywybBCOXi0ym04LVosJwvZN2hOKatvO6/P1HkOw5Qfu+rwQLuKsZMrcdzJXzNN8L0NiJiPu6AStw==
924862
dependencies:
925-
"@tensorflow/tfjs-converter" "0.7.0"
926-
"@tensorflow/tfjs-core" "0.14.0"
927-
"@tensorflow/tfjs-data" "0.1.2"
928-
"@tensorflow/tfjs-layers" "0.9.0"
929-
930-
"@types/long@^4.0.0":
931-
version "4.0.0"
932-
resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.0.tgz#719551d2352d301ac8b81db732acb6bdc28dbdef"
933-
integrity sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q==
934-
935-
"@types/long@~3.0.32":
936-
version "3.0.32"
937-
resolved "https://registry.yarnpkg.com/@types/long/-/long-3.0.32.tgz#f4e5af31e9e9b196d8e5fca8a5e2e20aa3d60b69"
938-
integrity sha512-ZXyOOm83p7X8p3s0IYM3VeueNmHpkk/yMlP8CLeOnEcu6hIwPH7YjZBvhQkR0ZFS2DqZAxKtJ/M5fcuv3OU5BA==
863+
"@tensorflow/tfjs-converter" "1.0.0"
864+
"@tensorflow/tfjs-core" "1.0.0"
865+
"@tensorflow/tfjs-data" "1.0.0"
866+
"@tensorflow/tfjs-layers" "1.0.0"
939867

940868
"@types/node-fetch@^2.1.2":
941869
version "2.1.4"
@@ -944,7 +872,7 @@
944872
dependencies:
945873
"@types/node" "*"
946874

947-
"@types/node@*", "@types/node@^10.1.0":
875+
"@types/node@*":
948876
version "10.12.18"
949877
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.18.tgz#1d3ca764718915584fcd9f6344621b7672665c67"
950878
integrity sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==
@@ -5902,11 +5830,6 @@ loglevel@^1.4.1:
59025830
resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.1.tgz#e0fc95133b6ef276cdc8887cdaf24aa6f156f8fa"
59035831
integrity sha1-4PyVEztu8nbNyIh82vJKpvFW+Po=
59045832

5905-
long@^4.0.0:
5906-
version "4.0.0"
5907-
resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28"
5908-
integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==
5909-
59105833
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
59115834
version "1.4.0"
59125835
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
@@ -7699,25 +7622,6 @@ prop-types@^15.6.2:
76997622
loose-envify "^1.3.1"
77007623
object-assign "^4.1.1"
77017624

7702-
protobufjs@~6.8.6:
7703-
version "6.8.8"
7704-
resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.8.8.tgz#c8b4f1282fd7a90e6f5b109ed11c84af82908e7c"
7705-
integrity sha512-AAmHtD5pXgZfi7GMpllpO3q1Xw1OYldr+dMUlAnffGTAhqkg72WdmSY71uKBF/JuyiKs8psYbtKrhi0ASCD8qw==
7706-
dependencies:
7707-
"@protobufjs/aspromise" "^1.1.2"
7708-
"@protobufjs/base64" "^1.1.2"
7709-
"@protobufjs/codegen" "^2.0.4"
7710-
"@protobufjs/eventemitter" "^1.1.0"
7711-
"@protobufjs/fetch" "^1.1.0"
7712-
"@protobufjs/float" "^1.0.2"
7713-
"@protobufjs/inquire" "^1.1.0"
7714-
"@protobufjs/path" "^1.1.2"
7715-
"@protobufjs/pool" "^1.1.0"
7716-
"@protobufjs/utf8" "^1.1.0"
7717-
"@types/long" "^4.0.0"
7718-
"@types/node" "^10.1.0"
7719-
long "^4.0.0"
7720-
77217625
proxy-addr@~2.0.4:
77227626
version "2.0.4"
77237627
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.4.tgz#ecfc733bf22ff8c6f407fa275327b9ab67e48b93"
@@ -9463,11 +9367,6 @@ use@^3.1.0:
94639367
resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"
94649368
integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==
94659369

9466-
utf8@~2.1.2:
9467-
version "2.1.2"
9468-
resolved "https://registry.yarnpkg.com/utf8/-/utf8-2.1.2.tgz#1fa0d9270e9be850d9b05027f63519bf46457d96"
9469-
integrity sha1-H6DZJw6b6FDZsFAn9jUZv0ZFfZY=
9470-
94719370
util-deprecate@~1.0.1:
94729371
version "1.0.2"
94739372
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"

0 commit comments

Comments
 (0)