Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't load model #5

Open
nukadelic opened this issue Oct 27, 2018 · 5 comments
Open

Can't load model #5

nukadelic opened this issue Oct 27, 2018 · 5 comments

Comments

@nukadelic
Copy link

I have uploaded the coco model shard# files to remote server but can't seem to load it, please have a look at : https://codesandbox.io/s/y083p9nz39

@justadudewhohacks
Copy link
Owner

The final url your loading the model from seems to be wrong: https://uploads.codesandbox.io/uploads/user/38363f64-0d83-4bc1-946f-9f741badbeed/1YLA-coco_model-weights_manifest_uploaded/-weights_manifest.json.

I think you forgot the .json file ending of the manifest file, that you are trying to load:

let modelWeightsManifest = "https://uploads.codesandbox.io/uploads/user/38363f64-0d83-4bc1-946f-9f741badbeed/1YLA-coco_model-weights_manifest_uploaded.json";

@nukadelic
Copy link
Author

The extra string in the end ( /-weights_manifest.json ) will be added to any file. just to make sure I attempted to referenced a picture URL, and it included this string as well. After some digging through the developer console I found the file where it's done: https://github.com/justadudewhohacks/tfjs-image-recognition-base/blob/master/src/common/getModelUris.ts#L2

without over complicating things, is it possible to load model from an imported JSON string? , like so:

import CocoWeights from '../model/coco_model-weights_manifest.json';
import CocoConfig from '../model/coco_model_config.json';
...
const net = new yolo.TinyYolov2(CocoConfig);
await net.load( CocoWeights );

This setup will produce the following error:
TinyYolov2.load - expected model uri, or weights as Float32Array

I got a similar setup working this way via tf.loadModel( tf.io.browserFiles( [ ... here is an example https://codesandbox.io/s/kor4m66poo?module=%2Fsrc%2FModelLoader.ts

@justadudewhohacks
Copy link
Owner

Maybe I did not fully understand, but as I said, you forgot the .json ending in your url. Thats why /-weights_manifest.json is appended to at the end, since what you give as input to the load function is not a valid uri to a json file.

To your second question, it will be possible to load the model from the json file as you suggested, once I publish the stuff I am currently working on.

@nukadelic
Copy link
Author

Nope sorry, you had it right the first time, I didn't pay full attention to your answer and got carried away. Will be waiting for the update with anticipation.

@justadudewhohacks
Copy link
Owner

It's now possible to load your model from the weight map using net.loadFromWeightMap(weightMap) where weightMap is what you retreive from tf.io.loadWeights.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants