zldrobit / tfjs-yolov5-example

TensorFlow.js example for YOLOv5
https://codesandbox.io/s/github/zldrobit/tfjs-yolov5-example
88 stars 30 forks source link

Support yolo v8 #21

Open KhoaVo opened 1 year ago

KhoaVo commented 1 year ago

It seems Yolo v8 is out and quite a bit better.

https://docs.ultralytics.com/tasks/detection/

Is it possible this repo would just work with an exported tfjs YOLO v8 model?

zldrobit commented 1 year ago

TFLite/tf.js is not supported by YOLOv8 at the moment. I'll see what I can do. By the way, the post process may be different. Maybe some code has to be tweaked to adapt to YOLOv8, but I believe it won't be too complicated.

QMjnh commented 1 year ago

YOLOv8 now supports tfjs but when I tried running this GitHub repo with my YOLOv8 model.json, I got the following error:

Uncaught (in promise) Error: Failed to parse model JSON of response from /web_model/model.json. Please make sure the server is serving valid JSON for this request.
    at HTTPRequest._callee2$ (http.ts:167:1)
    at tryCatch (regeneratorRuntime.js:44:1)
    at Generator.<anonymous> (regeneratorRuntime.js:125:1)
    at Generator.throw (regeneratorRuntime.js:69:1)
    at asyncGeneratorStep (asyncToGenerator.js:3:1)
    at _throw (asyncToGenerator.js:25:1)

manifest.json:1  Manifest: Line: 1, column: 1, Syntax error.

I thought this was because something went wrong when I tried to link the weights to the public directory (I don't really sure how to do that in Windows), so I tried hosting the JSON file and changing the const weights to const weights = 'http://localhost:8080/best_web_model/model.json. This time, the code was able to parse the JSON but I still got this error:

ERROR
Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.
TypeError: Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.
    at _nonIterableRest (http://localhost:3000/tfjs-yolov5-example/static/js/bundle.js:168365:9)
    at _slicedToArray (http://localhost:3000/tfjs-yolov5-example/static/js/bundle.js:168772:310)
    at http://localhost:3000/tfjs-yolov5-example/static/js/bundle.js:96:154

Sorry for the long comment, but how can I fix this? And can you please check whether the code works for YOLOv8 or if this error comes from my side?