Comments (17)
This looks like a node-red issue but still poking about. looks like a breaking change from last time I wrote a node in node-red..... oh the world keeps turning.
from face-api.
https://medium.com/@pencilflip/using-es-modules-with-commonjs-modules-in-node-js-1015786dab03
CommonJS
from face-api.
Could the fix be this simple ?
https://github.com/meeki007/face-api/blob/master/package.json
building and testing now. if it works ill send you a pull request
from face-api.
let vladmandic_face_api_js_module_check = module_check('test_fork_vladmandic_face-api/dist/face-api.node.js');
now returns true and not a ES Module error.
Pull request ---> #13
from face-api.
i'm at loss at different packagers.
- if i use
.csj
extension for commonjs builds, it works in 90%, of cases butwebpack
bundler complains about cjs being unknown extension - if i use
.js
extension, it works fine in 90% of cases, butnode-red
incorrectly complains about that being an esm module - cannot change global
type: module
since that is required for proper esm imports which is more common use-case
if you find a solution that works across the board, let me know.
from face-api.
Fixed pull request ---> #14
from face-api.
@vladmandic > cannot change global type: module since that is required for proper esm imports which is more common use-case
Oh its a nightmare. I've been reading all about it. It looks like it is fixed as a warning and not an error in nodJS14 but your supporting this for nodeJS 12 and that is the build most people use right now.
why can you not change to type: module for just the nodeJS stuff like I show in my pull request? did you not make face-api.node.js for just this use case ??? esm is not needed in the CommonJS
from face-api.
how? there can only be one type
definition in package.json
active (last one listed will be active, others will be ignored)
so settings type: commonjs
will "fix" cjs
builds, but break esm
builds. and cannot have multiple package.json
i'll try removing type
definition completely, it works for my other libraries
from face-api.
oh I can try and test that too. I am not at your skill level with npm. I did not know you could not use type : twice ......... hmmmmm
I'm happy to test and work anything and submit any trick I think may work in a pull request.
I know you would like to have a face-api package that works for all ....but......it may have to get split into 2 :(
from face-api.
I'm reading up https://2ality.com/2019/10/hybrid-npm-packages.html
see section 2.2 and 2.3
I need a hour or two ta wrap my head around this issue.
from face-api.
that solution relies on multiple package.json
files in separate directories - ugly.
i'm working on something, should publish within an hour.
from face-api.
i've just pushed new version 0.8.7 that removes type definition from package.json
and lets client self-determine module type instead.
also added nodejs example in demo/node.js
(that also answers your earlier question about canvas requirement - it works without it)
in my test case it works with both node using cjs
build and browser using esm
build
on a separate note, can i ask you to take a look at https://github.com/vladmandic/human?
from face-api.
Testing 0.8.7 version now.
Side note: https://github.com/vladmandic/human
Oh that is pretty cool. I just finished looking at the demo/node.js
It looks like I can just feed it an image and give it a place to store the output using the:
async function detect(input, output)
I'll have to write up some code to handle the error handling and log for node-red but it is a good node.js example you have.
Give me until this Sunday to get back to you on 'human' if it works I may make it a node-red node as well :) I'm sure you looked me up on NPM; 1/2 the time time use more skilled peoples work and packag them into node-red nodes. I always give a link to the original authors work if someone wants to see who did the core.
from face-api.
It looks like I can just feed it an image and give it a place to store the output using the:
actual processing does not require canvas if you feed it pre-processed tensor (that's what node.js demo does)
but you need canvas or something else to be able to draw processed images
Give me until this Sunday to get back to you on 'human' if it works I may make it a node-red node as well
human
on its own is fully nodejs
compatible (tested), but...
some models it uses are not yet - there is an open issue with tfjs
to implement one missing function in tfjs-node
backend
i'm in touch with tfjs
devs daily, it should not be long
and package them into node-red nodes
yup, that is cool!
from face-api.
let vladmandic_face_api_js_module_check = module_check('@vladmandic/face-api/dist/face-api.node.js');
in version 0.8.8 now returns true and not an error msg.
Thanks for the example/node.js for face-api---- I'm going to be writing 1/2 the stuff in my code over now :P I liked seeing:
${str(faceapi.tf?.version_core
deff going to use that gem.
nice to see node-fetch can be used for the monkeyPatch too!
I plan on using:
const tf = require('@tensorflow/tfjs-node');
const faceapi = require('@vladmandic/face-api/dist/face-api.node.nobundle.js');
or
const tf = require('@tensorflow/tfjs-node-gpu');
const faceapi = require('@vladmandic/face-api/dist/face-api.node.nobundle.js');
based on detections like i did for the original face-api
example:
// check if module @tensorflow/tfjs-node [GPU] is installed and working;
let tfjs_node_gpu_module_check = module_check('@tensorflow/tfjs-node-gpu');
// check if module @tensorflow/tfjs-node [CPU] is installed and working;
let tfjs_node_cpu_module_check = module_check('@tensorflow/tfjs-node');
ran a check for !true and then loaded the required as needed based on users installed packages.
I still plan on showing examples of that in a howto for other users here that want to use your fork :)
I'm not as quick as you with the code so need time
thanks again for the fix.
Care to link your donations page so I can buy you a 6 pack of beer ?
Meeki007
from face-api.
deff going to use that gem.
keep in mind that new syntax is part of ES2018
so don't use if you need to target older platforms (don't know why people still target ES2015 to be honest)
nice to see node-fetch can be used for the monkeyPatch too!
node-fetch
can be used for monkeyPatch
, but no need anymore (I just removed it from demo)
since faceapi
has native .loadFromDisk()
await faceapi.nets.ssdMobilenetv1.loadFromDisk(modelPath);
and in human
, it simply doesn't care, it's all handled behind the scenes
if you want to load from http, you give it http:// link
and if you want to load from file, you give it file:// link.
Care to link your donations page so I can buy you a 6 pack of beer ?
lol! thanks :)
i do this for myself, not as a job - but since quite a lot of code i use is opensource, i publish what i do as well :)
from face-api.
closing as resolved
from face-api.
Related Issues (20)
- Demo Launch Issue HOT 1
- Different face detection and match results between browser and server HOT 5
- Pitch is not good when Yaw is <-150ΒΊ or >150ΒΊ HOT 1
- Face-api.js In React native HOT 1
- Is it possible to translate it? HOT 1
- Face api gives an error when there are too many photos HOT 3
- Error: Based on the provided shape, [1,1,16,32], the tensor should have 512 values but has 48 HOT 2
- Unhandled Promise Rejection: TypeError: null is not an object (evaluating 'e.isContextLost') HOT 1
- Trying to load tfjs-node externally to be able to deploy on vercel. HOT 2
- Usage with Google Cloud Functions HOT 8
- A bit confusing, old version cpu, gpu issues & new wasm flow HOT 1
- System requirements HOT 1
- node multiprocess on GPU HOT 4
- Object Detection HOT 1
- Can this lib use with RTSP Streaming Video From IP Camera? HOT 2
- Error while using faceapi in angular HOT 1
- Cant we use models from node modules and decrease models file size? HOT 3
- Initialization of backend wasm failed HOT 1
- Detached EventHandlers when running on a Canvas HOT 3
- Support for TSC verbatimModuleSyntax HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from face-api.