juandes / tensorflowjs-objectdetection-tutorial

72 stars 30 forks source link

Applying to a existing video #1

Closed methmal59 closed 3 years ago

methmal59 commented 4 years ago

Hi How can I use the tool to an existing video? I've set up everything and they work fine. I need to use it for a video that I have in my local storage.

juandes commented 4 years ago

Hi, This is what I'd do. First load your video with something like this:

var video = document.createElement("video");
video.setAttribute("src", "yourvideo.mp4");

Then, on this line, replace the video object with the var I just declared.

After that, you'll have to refactor the code and get rid of all the webcam functionality. Hope this helps.

methmal59 commented 4 years ago

I tried that, but still, I'm stuck. I removed everything related to the webcam and added my video as a var, Program complies successfully but it doesn't display anything on the webpage, Any suggestions would be great.

juandes commented 4 years ago

I'd start with the basics. First, make sure the video is displayed on the screen. Second, make sure there are no CORS-related issues. What errors are you receiving? Have you checked the console?

methmal59 commented 4 years ago
Error: Failed to parse model JSON of response from /model_web/model.json. Please make sure the server is serving valid JSON for this request.
    at e.<anonymous> (tf-core.esm.js:15350)
    at tf-core.esm.js:153
    at Object.throw (tf-core.esm.js:166)
    at s (tf-core.esm.js:61)

This is the error I'm receiving at the 'Promise.all' line. It catches this error. That's the only error I'm getting

aswinkumar2019 commented 4 years ago

Hello @methmal59 , Were you successfully able to fix it???? If so,what are the changes you made to the code???? Can you please guide me in making it work for me Regards, Aswin Kumar

juandes commented 4 years ago

Hi,

Since this is a recurrent issue, I added a solution on the detect-from-video branch. You can find the diff, here:

https://github.com/juandes/tensorflowjs-objectdetection-tutorial/compare/detect-from-video

In short, remove the webcam stuff, and on the