mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

Launching mediapipe in node.js

Open mr-grixa opened this issue 1 year ago • 0 comments

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

Yes

OS Platform and Distribution

windows 10

Mobile device if the issue happens on mobile device

No response

Browser and version if the issue happens on browser

No response

Programming Language and version

javascript

MediaPipe version

No response

Bazel version

No response

Solution

Holistic

Android Studio, NDK, SDK versions (if issue is related to building in Android environment)

No response

Xcode & Tulsi version (if issue is related to building for iOS)

No response

Describe the actual behavior

The detector does not return values

Describe the expected behaviour

The detector does return values

Standalone code/steps you may have used to try to get what you need

const fs = require('fs')
const holistic = require('@mediapipe/holistic');
const { JSDOM } = require('jsdom');

const dom = new JSDOM();
const window = dom.window;

const document = window.document;
const navigator = window.navigator;
global.navigator = navigator;
global.window = window;
global.document = document;

const path = require('path');
const holisticDetector = new holistic.Holistic({
  locateFile: (file) => {
    return `https://cdn.jsdelivr.net/npm/@mediapipe/holistic/${file}`;
  }
});

holisticDetector.setOptions({
  modelComplexity: 0,
  smoothLandmarks: false, 
  minDetectionConfidence: 0.5,
  minTrackingConfidence: 0.5 
});

holisticDetector.onResults((results) => {
  console.log(results);
});

const image = fs.readFileSync('image.jpg');
holisticDetector.initialize()
const predictions =holisticDetector.send({image: 1})
  .then(predictions => {
    console.log(predictions); 
  }).catch(err => {
    console.error('Send error:', err); 
  });;
console.log(predictions);

Other info / Complete Logs

I'm trying to run @mediapipe/holistic in node.js. I followed the guidance from here #1411 and used JSDOM. The code doesn't throw any errors but also doesn't produce any results. I also noticed that in holisticDetector.send any data can be passed in, behavior doesn't change. Instead of results, I'm getting: Promise {[[PromiseState]]: 'pending', [[PromiseResult]]: undefined, Symbol(async_id_symbol): 41, Symbol(trigger_async_id_symbol): 40} Symbol(async_id_symbol): 41 Symbol(trigger_async_id_symbol): 40 [[PromiseResult]]: undefined [[PromiseState]]: 'pending' [[Prototype]]: Promise

mr-grixa avatar Feb 12 '24 09:02 mr-grixa