New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use in a lerna/create-react app project #5
Comments
What are your Looks like I've compiled Face-API using newer ECMA standard that your project does not recognize. Original Face-API used ES2015 and I'm using ES2018. If you're using TypeScript, you can try importing TS sources directly so it gets rebuild along your application:
Or check docs on how to rebuild Face-API after modifying it's
|
Thanks for the quick reply! Can I just change my tsconfig to use ES2018 instead? |
Sure 😁 |
using es2018 I get a better error message now :) ../face-detect-plugin/node_modules/@tensorflow/tfjs-backend-cpu/dist/kernels/Abs.js Questions:
Thanks |
Actually the console have many more errors regarding not found modules: log.js:24 [HMR] Waiting for update signal from WDS... |
Q: Why can't it just work like the original face-api? TFJS 2.x is not fully compatible with TFJS 1.x. Q: Why need to install both face-api and tfjs if tfjs is a dependency of face-api? TFJS 1.x was a simple package. Q: Why with the original face-api I don't need to import tfjs for it to compile? In short, I though that bundling entire TFJS 2.x makes But as you've stated (and others as well), people prefer simplicity over modularity so I'll make it so. I'll publish a new version of FaceAPI shortly that includes TFJS and does not require any extra imports. |
Hi, I really appreciate your quick and detailed responses. I actually like tfjs not bundled since I am using it in another audio related detection code and prefer to control which version I use. I was just wondering since I saw it is a dependency in your package.json and not a peer dependency. Do you have any idea how to resolve the errors? It seems the code cannot locate the core and other tf libraries. I can wait for your new version if its coming soon or find a workaround like including it in the html as a script so the bundler will not process it? |
An another question, is there a chance of using face-api with webworkers so it won't block the UI thread? I know its possible with tfjs itself. |
New version is almost ready, I'm updating the docs now and should be published within an hour. Regarding WebWorkers - It's possible, but somewhat outside of the scope of what I've intended with this port of FaceAPI (it's already much more work than I envisioned). One of the issues is that FaceAPI internally uses standard I'll try to include that in my new library (hopefully by the end of this week). |
thanks, that will be amazing! |
New version |
Cannot find module '@vladmandic/face-api' or its corresponding type declarations. |
silly me, that's what happens when you rush and publish without proper testing. republished - 0.7.2. |
same I think because "typings": "build/index.d.ts" is actually in src? |
it's in |
Now I don't need to import tfjs before face-api but I get this error now because the faceapi returned from the import is an empty object {}. Also I think now tfjs should be a dependency and not devDependeny or peerDepenedency. Also you should probably use tfsj as npm module and use the dist/tf.es2017.js. Probably need to take a step back and rethink the whole module thing. Most people these days use modules and a. bundler. TypeError: faceapi.TinyFaceDetectorOptions is not a constructor
|
Ok could make it work with import * as faceapi from '@vladmandic/face-api/dist/face-api.esm' and then declare module "@vladmandic/face-api/dist/face-api.esm" But lost all the typings, it is ok for now but we will happy to help get the module stuff to work with types Thanks! |
You were correct:
{
// old default
"browser": "dist/face-api.js",
// should be
"browser": "dist/face-api.esm.js",
} and as you saw, you can manually specify which version to include: // will import default
import * as faceapi from '@vladmandic/face-api';
// esm with tfjs bundled, this is now the default
import * as faceapi from '@vladmandic/face-api/dist/face-api.esm.js';
// esm without tfjs bundled, you must manually include @tensorflow/tfjs before importing face-api
import * as faceapi from '@vladmandic/face-api/dist/face-api.nobundle.js'; as you can see, I've now added both prebundled and nobundle versions, you can pick which one you want to use. regarding dependencies, it only means should |
Will I get the typings this way? |
it should. |
it works now! never had such responsiveness in an open source project :) thanks What is the new library, maybe face-api with webworkers? |
thanks :) new library is using totally different models and is written from scratch - i found that less frustrating than trying to modify you can take a look at a prerelease: https://github.com/vladmandic/human |
closing as resolved |
I am using the library in a TypeScript lerna module which is build with tsc and then bundled as part of a create-react-app. I had no issue with the original face-api but wanted the latest fdjs. I am using the npm module with npm install.
If I only do:
import * as faceapi from '@vladmandic/face-api'
I get a compile error:
Failed to compile
../face-detect-plugin/node_modules/@vladmandic/face-api/dist/face-api.js 344:47
Module parse failed: Unexpected token (344:47)
File was processed with these loaders:
You may need an additional loader to handle the result of these loaders.
| } : T || {};
|
| F = new d(_),
| D = function () {
if I add:
import * as tf from '@tensorflow/tfjs'
before importing face-api then I get an error in the console:
Uncaught SyntaxError: Unexpected token '!'
If I look at the code I see this:
class MathBackendCPU extends !(function webpackMissingModule() { var e = new Error("Cannot find module '@tensorflow/tfjs-core'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()) {
constructor() {
super();
this.blockSize = 48;
this.firstUse = true;
this.data = new !(function webpackMissingModule() { var e = new Error("Cannot find module '@tensorflow/tfjs-core'"); e.code = 'MODULE_NOT_FOUND'; throw e; }())(this, !(function webpackMissingModule() { var e = new Error("Cannot find module '@tensorflow/tfjs-core'"); e.code = 'MODULE_NOT_FOUND'; throw e; }())());
}
The text was updated successfully, but these errors were encountered: