简体   繁体   中英

File reference in Chrome extension

I would like to load a model in contentScript.js using url './model/model.json'

const MODEL_URL = './model/model.json';
const model = tf.loadLayersModel(MODEL_URL);

but keep getting Request to model/model.json failed with status code 404. Please verify this URL points to the model JSON of the model to load. Could not figure out what went wrong. I also tried '../model/model.json' , 'model/model.json' , './model/model' et. al..

├── build
│   ├── icons
│   │   ├── ...
│   ├── model
│   │   ├──model.json
│   ├── contentScript.js

Update :

Added "web_accessible_resources": [ "models/*" ] to manifest.json , still get 404.

use getURL():

tf.loadLayersModel(chrome.runtime.getURL(MODEL_URL));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM