facebookresearch / segment-anything

The repository provides code for running inference with the SegmentAnything Model (SAM), links for downloading the trained model checkpoints, and example notebooks that show how to use the model.
Apache License 2.0
47.87k stars 5.66k forks source link

DEMO WARNING: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted #777

Open WCH-Jason opened 1 month ago

WCH-Jason commented 1 month ago

This warning occurred after I built and ran yarn, and I asked GPT that it could be ignored if it did not affect the operation of the project, but after I turned off the warning, nothing could be displayed on the web page (blank page) 屏幕截图 2024-10-08 145249 屏幕截图 2024-10-08 151802 屏幕截图 2024-10-08 151922

Beasleydog commented 1 month ago

Did you figure this out?

moersxm commented 1 month ago

i got the same problem

whut-zhangwx commented 1 month ago

+1, same problem

TonyLianLong commented 4 weeks ago

The solution is to update package.json to use "onnxruntime-web": "1.14.0", (rather than "onnxruntime-web": "^1.14.0", as it is in the repo). This will ensure v1.14.0 to be installed. Then rerun yarn to install the right version of the package. I also find that the onnx needs to be exported with onnx==1.13.1 and onnxruntime==1.13.1 rather than the latest versions of these two packages. These two are python packages that can be installed with pip.

takerfume commented 3 weeks ago

@TonyLianLong This helped me!

In addition, when I use python 3.12 and numpy 2.x, this demo didn't work. But when I use python 3.10.5 and numpy 1.23.3, it worked.