transcranial / keras-js

Run Keras models in the browser, with GPU support using WebGL
https://transcranial.github.io/keras-js
MIT License
4.96k stars 503 forks source link

Error loading the model (weights) #120

Closed imageschool closed 1 year ago

imageschool commented 6 years ago

Hi, I have used encoder.py (v0.3) to get my weight changed to convert my own Keras model into .buf file, however when I am loading it, I get following error...............

Is it still because my Keras version was >2 ?

Help would be really really appreciated..

{ Error: connect ECONNREFUSED 127.0.0.1:80 [1] at Object._errnoException (util.js:1022:11) [1] at _exceptionWithHostPort (util.js:1044:20) [1] at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1198:14) [1] code: 'ECONNREFUSED', [1] errno: 'ECONNREFUSED', [1] syscall: 'connect', [1] address: '127.0.0.1', [1] port: 80, [1] config: [1] { adapter: [Function: httpAdapter], [1] transformRequest: { '0': [Function: transformRequest] }, [1] transformResponse: { '0': [Function: transformResponse] }, [1] timeout: 0, [1] xsrfCookieName: 'XSRF-TOKEN', [1] xsrfHeaderName: 'X-XSRF-TOKEN', [1] maxContentLength: -1, [1] validateStatus: [Function: validateStatus], [1] headers: [1] { Accept: 'application/json, text/plain, /', [1] 'User-Agent': 'axios/0.17.1' }, [1] method: 'get', [1] responseType: 'arraybuffer', [1] onDownloadProgress: [Function: onDownloadProgress], [1] cancelToken: CancelToken { promise: [Object] }, [1] url: 'C:/React/clippy/model-vgg19_weights.buf', [1] data: undefined }, [1] request: [1] Writable { [1] _writableState: [1] WritableState { [1] objectMode: false, [1] highWaterMark: 16384, [1] finalCalled: false, [1] needDrain: false, [1] ending: false, [1] ended: false, [1] finished: false, [1] destroyed: false, [1] decodeStrings: true, [1] defaultEncoding: 'utf8', [1] length: 0, [1] writing: false, [1] corked: 0, [1] sync: true, [1] bufferProcessing: false, [1] onwrite: [Function: bound onwrite], [1] writecb: null, [1] writelen: 0, [1] bufferedRequest: null, [1] lastBufferedRequest: null, [1] pendingcb: 0, [1] prefinished: false, [1] errorEmitted: false, [1] bufferedRequestCount: 0, [1] corkedRequestsFree: [Object] }, [1] writable: true, [1] domain: null, [1] _events: [1] { response: [Function: handleResponse], [1] error: [Function: handleRequestError] }, [1] _eventsCount: 2, [1] _maxListeners: undefined, [1] _options: [1] { protocol: 'http:', [1] maxRedirects: 21, [1] maxBodyLength: 10485760, [1] hostname: '', [1] port: null, [1] path: '/React/clippy/model-vgg19_weights.buf', [1] method: 'get', [1] headers: [Object], [1] agent: undefined, [1] auth: undefined, [1] nativeProtocols: [Object], [1] pathname: '/React/clippy/model-vgg19_weights.buf' }, [1] _redirectCount: 0, [1] _requestBodyLength: 0, [1] _requestBodyBuffers: [], [1] _onNativeResponse: [Function], [1] _currentRequest: [1] ClientRequest { [1] domain: null, [1] _events: [Object], [1] _eventsCount: 6, [1] _maxListeners: undefined, [1] output: [], [1] outputEncodings: [], [1] outputCallbacks: [], [1] outputSize: 0, [1] writable: true, [1] _last: true, [1] upgrading: false, [1] chunkedEncoding: false, [1] shouldKeepAlive: false, [1] useChunkedEncodingByDefault: false, [1] sendDate: false, [1] _removedConnection: false, [1] _removedContLen: false, [1] _removedTE: false, [1] _contentLength: 0, [1] _hasBody: true, [1] _trailer: '', [1] finished: true, [1] _headerSent: true, [1] socket: [Object], [1] connection: [Object], [1] _header: 'GET /React/clippy/model-vgg19_weights.buf HTTP/1.1\r\nAccept: application/json, text/plain, /\r\nUser-Agent: axios/0.17.1\r\nHost: localhost\r\nConnection: close\r\n\r\n', [1] _onPendingData: [Function: noopPendingOutput], [1] agent: [Object], [1] socketPath: undefined, [1] timeout: undefined, [1] method: 'GET', [1] path: '/React/clippy/model-vgg19_weights.buf', [1] _ended: false, [1] res: null, [1] aborted: undefined, [1] timeoutCb: null, [1] upgradeOrConnect: false, [1] parser: null, [1] maxHeadersCount: null, [1] _redirectable: [Circular], [1] [Symbol(outHeadersKey)]: [Object] }, [1] _currentUrl: 'http:/React/clippy/model-vgg19_weights.buf' }, [1] response: undefined } [1] (node:12808) UnhandledPromiseRejectionWarning: Error: [Model] Model configuration does not contain any layers. [1] at Model._buildDAG (c:\React\clippy\node_modules\keras-js\lib\Model.js:234:13) [1] at Model._initialize (c:\React\clippy\node_modules\keras-js\lib\Model.js:121:10) [1] at [1] at process._tickCallback (internal/process/next_tick.js:188:7) [1] (node:12808) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) [1] (node:12808) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

ghost commented 6 years ago

I solved my weights loading problems by modifying the python/encode.py file. Basically there is a name mismatch between h5 and what is encoded by that file, I think due to versions issues, but not sure. Anyway I pushed the fix to my repo https://github.com/NPolikurov/keras-js