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
46.83k stars 5.55k forks source link

the web demo local deploy throw error "Unexpected token 'h', "html> ... " #416

Open huzhenhong opened 1 year ago

huzhenhong commented 1 year ago
$ npm install        
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: friendly-errors-webpack-plugin@1.7.0
npm ERR! Found: webpack@5.85.0
npm ERR! node_modules/webpack
npm ERR!   dev webpack@"^5.74.0" from the root project
npm ERR!   peer webpack@">=4.43.0 <6.0.0" from @pmmmwh/react-refresh-webpack-plugin@0.5.10
npm ERR!   node_modules/@pmmmwh/react-refresh-webpack-plugin
npm ERR!     dev @pmmmwh/react-refresh-webpack-plugin@"^0.5.7" from the root project
npm ERR!   17 more (@webpack-cli/configtest, babel-loader, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^2.0.0 || ^3.0.0 || ^4.0.0" from friendly-errors-webpack-plugin@1.7.0
npm ERR! node_modules/friendly-errors-webpack-plugin
npm ERR!   dev friendly-errors-webpack-plugin@"^1.7.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: webpack@4.46.0
npm ERR! node_modules/webpack
npm ERR!   peer webpack@"^2.0.0 || ^3.0.0 || ^4.0.0" from friendly-errors-webpack-plugin@1.7.0
npm ERR!   node_modules/friendly-errors-webpack-plugin
npm ERR!     dev friendly-errors-webpack-plugin@"^1.7.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /root/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2023-06-05T06_34_34_657Z-debug-0.log

then use "npm install --legacy-peer-deps or npm install --force"

$ yarn && yarn start
yarn install v1.22.19
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.46s.
yarn run v1.22.19
$ yarn run start-dev
$ webpack serve --config=configs/webpack/dev.js
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:8081/
<i> [webpack-dev-server] Content not from webpack is served from '/root/huzh_work/code/segment-anything/demo/public' directory
<i> [webpack-dev-middleware] wait until bundle finished: /

 DONE  Compiled successfully in 5772ms                                                                               7:12:47 PM

assets by path *.wasm 71.1 MiB
  asset ort-wasm-simd-threaded.jsep.wasm 17.4 MiB [emitted] [from: node_modules/onnxruntime-web/dist/ort-wasm-simd-threaded.jsep.wasm] [copied]
  asset ort-wasm-simd.jsep.wasm 16.1 MiB [emitted] [from: node_modules/onnxruntime-web/dist/ort-wasm-simd.jsep.wasm] [copied]
  asset ort-wasm-simd.wasm 9.86 MiB [emitted] [from: node_modules/onnxruntime-web/dist/ort-wasm-simd.wasm] [copied]
  asset ort-wasm-simd-threaded.wasm 9.81 MiB [emitted] [from: node_modules/onnxruntime-web/dist/ort-wasm-simd-threaded.wasm] [copied]
  + 2 assets
assets by path assets/ 439 KiB
  asset assets/data/dogs.jpg 438 KiB [emitted] [from: src/assets/data/dogs.jpg] [copied]
  asset assets/index.html 532 bytes [emitted] [from: src/assets/index.html] [copied]
  asset assets/scss/App.scss 59 bytes [emitted] [from: src/assets/scss/App.scss] [copied]
assets by path model/*.onnx 8.27 MiB
  asset model/sam_vit_b_01ec64_quantized.onnx 8.27 MiB [emitted] [from: model/sam_vit_b_01ec64_quantized.onnx] [copied]
  asset model/sam_onnx_quantized_example.onnx 0 bytes [emitted] [from: model/sam_onnx_quantized_example.onnx] [copied]
asset main.js 2.24 MiB [emitted] (name: main) 1 related asset
asset index.html 569 bytes [emitted]
runtime modules 27.5 KiB 14 modules
modules by path ./node_modules/underscore/modules/*.js 83.1 KiB 161 modules
modules by path ./node_modules/webpack-dev-server/client/ 71.8 KiB 16 modules
modules by path ./src/ 30.9 KiB 11 modules
modules by path ./node_modules/style-loader/dist/runtime/*.js 5.84 KiB 6 modules
modules by path ./node_modules/webpack/hot/*.js 5.3 KiB 4 modules
modules by path ./node_modules/html-entities/lib/*.js 81.3 KiB 4 modules
modules by path ./node_modules/react-dom/ 1000 KiB 3 modules
modules by path ./node_modules/react/ 85.7 KiB 2 modules
modules by path ./node_modules/scheduler/ 17.3 KiB 2 modules
modules by path ./node_modules/css-loader/dist/runtime/*.js 2.74 KiB 2 modules
+ 6 modules
webpack 5.85.0 compiled successfully in 5772 ms
image

the demo folder nothing have modified but MODEL_DIR, and my node version is v18.12.0 and the same as v14.21 CentOS7.9 kernel 3.10.0-957.el7.x86_64

sanbuphy commented 1 year ago

the same

abinash-kumar commented 1 year ago

@sanbuphy @sanbuphy please check your network tab you will get some fetch call and that call must be getting failed to fetch

you guys need add all the files and the try to run the project

image

IMAGE_PATH This is the image path IMAGE_EMBEDDING This file has all the embedding information and it will be different for different image MODEL_DIR This is SAM model it can remain same

huzhenhong commented 1 year ago

@abinash-kumar thanks, i use the sam_vit_b_01ec64.pth to generate "dogs_embedding.npy", no it works

btw, is the demo only support hover mode?

wxjttxs commented 1 year ago

sam_vit_b_01ec64

hello, where did you download this checkpoint? could you show me this link? thank you so much.

gwyanCN commented 8 months ago

@abinash-kumar thanks, i use the sam_vit_b_01ec64.pth to generate "dogs_embedding.npy", no it works

btw, is the demo only support hover mode?

the same question

RemyNtshaykolo commented 6 months ago

using

const IMAGE_PATH = "src/assets/data/dogs_embedding.png";
const IMAGE_EMBEDDING = "src/assets/data/dogs_embedding.npy";

fixed the error. Basically, the file where not found and an html error file was returned.