Skip to content
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

Use ImageSegmenter instance as reactive leads to exception #5592

Open
amiznikov opened this issue Aug 28, 2024 · 0 comments
Open

Use ImageSegmenter instance as reactive leads to exception #5592

amiznikov opened this issue Aug 28, 2024 · 0 comments
Assignees
Labels
os:macOS Issues on MacOS platform:javascript MediaPipe Javascript issues task:image segmentation Issues related to image segmentation: Locate objects and create image masks with labels type:bug Bug in the Source Code of MediaPipe Solution

Comments

@amiznikov
Copy link

amiznikov commented Aug 28, 2024

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

None

OS Platform and Distribution

MacOS Sonoma 14.5

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, Vue.js

MediaPipe version

0.10.14

Bazel version

No response

Solution

ImageSegmenter

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

Got a mistake "Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'."

Describe the expected behaviour

Don't get it)

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

I have component based on Vue.js where I try to launch ImageSegmenter

<script>
import { ImageSegmenter, FilesetResolver } from "@mediapipe/tasks-vision";
export default {
  name: 'MediaPipe',
  mounted() {
    this.startStream();
  },
  data() {
    return {
          imageSegmenter: null,
        };
  },
  methods: {
    async startStream() {
      try {
        const audio = await FilesetResolver.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.2/wasm");
        this.imageSegmenter = await ImageSegmenter.createFromOptions(audio, {
          baseOptions: {
            modelAssetPath: "https://storage.googleapis.com/mediapipe-models/image_segmenter/selfie_segmenter/float16/latest/selfie_segmenter.tflite",
            delegate: "GPU"
          },
          runningMode: "VIDEO",
          outputCategoryMask: true,
          outputConfidenceMasks: false
        });
        const stream = await navigator.mediaDevices.getUserMedia({ video: {
          width: 940,
          height: 560,
            frameRate: {
            ideal: 30,
              max: 30
            }
          } });
        this.$refs.video.srcObject = stream;
        this.$refs.video.addEventListener("loadeddata", () => {
          let startTimeMs = performance.now();
          // Start segmenting the stream.
          this.imageSegmenter.segmentForVideo(this.$refs.video, startTimeMs, async(result) => {
            console.log(result);
          });
        })

      } catch (error) {
        console.error('Ошибка при получении доступа к веб-камере:', error);
      }
    }
  }
};
</script>

<template>
  <video ref="video" muted autoplay playsinline></video>


</template>

and I got exception
"Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'"
But If change my code
this.imageSegmenter = markRaw(await ImageSegmenter.createFromOptions(....);)
everything works fine
I guess this.imageSegmenter is not a plain ImageSegmenter it's wrapped Proxy, 'cause every data object is reactive in Vue.js

Other info / Complete Logs

No response

@amiznikov amiznikov added the type:bug Bug in the Source Code of MediaPipe Solution label Aug 28, 2024
@kuaashish kuaashish added os:macOS Issues on MacOS platform:javascript MediaPipe Javascript issues task:image segmentation Issues related to image segmentation: Locate objects and create image masks with labels labels Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os:macOS Issues on MacOS platform:javascript MediaPipe Javascript issues task:image segmentation Issues related to image segmentation: Locate objects and create image masks with labels type:bug Bug in the Source Code of MediaPipe Solution
Projects
None yet
Development

No branches or pull requests

2 participants