Git Product home page Git Product logo

Comments (17)

meeki007 avatar meeki007 commented on May 17, 2024

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.

meeki007 avatar meeki007 commented on May 17, 2024

https://medium.com/@pencilflip/using-es-modules-with-commonjs-modules-in-node-js-1015786dab03

CommonJS

from face-api.

meeki007 avatar meeki007 commented on May 17, 2024

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.

meeki007 avatar meeki007 commented on May 17, 2024
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.

vladmandic avatar vladmandic commented on May 17, 2024

i'm at loss at different packagers.

  • if i use .csj extension for commonjs builds, it works in 90%, of cases but webpack bundler complains about cjs being unknown extension
  • if i use .js extension, it works fine in 90% of cases, but node-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.

meeki007 avatar meeki007 commented on May 17, 2024

Fixed pull request ---> #14

from face-api.

meeki007 avatar meeki007 commented on May 17, 2024

@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.

vladmandic avatar vladmandic commented on May 17, 2024

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.

meeki007 avatar meeki007 commented on May 17, 2024

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.

meeki007 avatar meeki007 commented on May 17, 2024

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.

vladmandic avatar vladmandic commented on May 17, 2024

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.

vladmandic avatar vladmandic commented on May 17, 2024

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.

meeki007 avatar meeki007 commented on May 17, 2024

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.

vladmandic avatar vladmandic commented on May 17, 2024
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.

meeki007 avatar meeki007 commented on May 17, 2024
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.

vladmandic avatar vladmandic commented on May 17, 2024
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.

vladmandic avatar vladmandic commented on May 17, 2024

closing as resolved

from face-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.