question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught Error: The dict provided in model.execute(dict) has keys that are not part of graph

See original GitHub issue

model used: custom training ultralytics yolo v5 converted to tensorflow saved model then to tensorflow js (quantized to uint8) when using model.predict getting this error,

  • OS Platform: Windows 10 Desktop Chrome
  • TensorFlow.js installed from (npm or script link): 2.7.0
  • Browser version: Version 86.0.4240.183 (Official Build) (64-bit)
  • Tensorflow.js Converter Version: 2.7.0

Uncaught Error: The dict provided in model.execute(dict) has keys: [alt,src,srcset,sizes,crossOrigin,useMap,isMap,width,height,naturalWidth,naturalHeight,complete,currentSrc,referrerPolicy,decoding,name,lowsrc,align,hspace,vspace,longDesc,border,x,y,decode,loading,title,lang,translate,dir,hidden,accessKey,draggable,spellcheck,autocapitalize,contentEditable,isContentEditable,inputMode,offsetParent,offsetTop,offsetLeft,offsetWidth,offsetHeight,style,innerText,outerText,onabort,onblur,oncancel,oncanplay,oncanplaythrough,onchange,onclick,onclose,oncontextmenu,oncuechange,ondblclick,ondrag,ondragend,ondragenter,ondragleave,ondragover,ondragstart,ondrop,ondurationchange,onemptied,onended,onerror,onfocus,onformdata,oninput,oninvalid,onkeydown,onkeypress,onkeyup,onload,onloadeddata,onloadedmetadata,onloadstart,onmousedown,onmouseenter,onmouseleave,onmousemove,onmouseout,onmouseover,onmouseup,onmousewheel,onpause,onplay,onplaying,onprogress,onratechange,onreset,onresize,onscroll,onseeked,onseeking,onselect,onstalled,onsubmit,onsuspend,ontimeupdate,ontoggle,onvolumechange,onwaiting,onwebkitanimationend,onwebkitanimationiteration,onwebkitanimationstart,onwebkittransitionend,onwheel,onauxclick,ongotpointercapture,onlostpointercapture,onpointerdown,onpointermove,onpointerup,onpointercancel,onpointerover,onpointerout,onpointerenter,onpointerleave,onselectstart,onselectionchange,onanimationend,onanimationiteration,onanimationstart,ontransitionend,oncopy,oncut,onpaste,dataset,nonce,autofocus,tabIndex,attachInternals,blur,click,focus,onpointerrawupdate,enterKeyHint,namespaceURI,prefix,localName,tagName,id,className,classList,slot,attributes,shadowRoot,part,assignedSlot,innerHTML,outerHTML,scrollTop,scrollLeft,scrollWidth,scrollHeight,clientTop,clientLeft,clientWidth,clientHeight,attributeStyleMap,onbeforecopy,onbeforecut,onbeforepaste,onsearch,elementTiming,onfullscreenchange,onfullscreenerror,onwebkitfullscreenchange,onwebkitfullscreenerror,onbeforexrselect,children,firstElementChild,lastElementChild,childElementCount,previousElementSibling,nextElementSibling,after,animate,append,attachShadow,before,closest,computedStyleMap,getAttribute,getAttributeNS,getAttributeNames,getAttributeNode,getAttributeNodeNS,getBoundingClientRect,getClientRects,getElementsByClassName,getElementsByTagName,getElementsByTagNameNS,hasAttribute,hasAttributeNS,hasAttributes,hasPointerCapture,insertAdjacentElement,insertAdjacentHTML,insertAdjacentText,matches,prepend,querySelector,querySelectorAll,releasePointerCapture,remove,removeAttribute,removeAttributeNS,removeAttributeNode,replaceWith,requestFullscreen,requestPointerLock,scroll,scrollBy,scrollIntoView,scrollIntoViewIfNeeded,scrollTo,setAttribute,setAttributeNS,setAttributeNode,setAttributeNodeNS,setPointerCapture,toggleAttribute,webkitMatchesSelector,webkitRequestFullScreen,webkitRequestFullscreen,ariaDescription,ariaAtomic,ariaAutoComplete,ariaBusy,ariaChecked,ariaColCount,ariaColIndex,ariaColSpan,ariaCurrent,ariaDisabled,ariaExpanded,ariaHasPopup,ariaHidden,ariaKeyShortcuts,ariaLabel,ariaLevel,ariaLive,ariaModal,ariaMultiLine,ariaMultiSelectable,ariaOrientation,ariaPlaceholder,ariaPosInSet,ariaPressed,ariaReadOnly,ariaRelevant,ariaRequired,ariaRoleDescription,ariaRowCount,ariaRowIndex,ariaRowSpan,ariaSelected,ariaSetSize,ariaSort,ariaValueMax,ariaValueMin,ariaValueNow,ariaValueText,getAnimations,replaceChildren,nodeType,nodeName,baseURI,isConnected,ownerDocument,parentNode,parentElement,childNodes,firstChild,lastChild,previousSibling,nextSibling,nodeValue,textContent,ELEMENT_NODE,ATTRIBUTE_NODE,TEXT_NODE,CDATA_SECTION_NODE,ENTITY_REFERENCE_NODE,ENTITY_NODE,PROCESSING_INSTRUCTION_NODE,COMMENT_NODE,DOCUMENT_NODE,DOCUMENT_TYPE_NODE,DOCUMENT_FRAGMENT_NODE,NOTATION_NODE,DOCUMENT_POSITION_DISCONNECTED,DOCUMENT_POSITION_PRECEDING,DOCUMENT_POSITION_FOLLOWING,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC,appendChild,cloneNode,compareDocumentPosition,contains,getRootNode,hasChildNodes,insertBefore,isDefaultNamespace,isEqualNode,isSameNode,lookupNamespaceURI,lookupPrefix,normalize,removeChild,replaceChild,addEventListener,dispatchEvent,removeEventListener] that are not part of graph at e.t.checkInputs (graph_executor.js:607) at e.t.execute (graph_executor.js:193) at e.t.execute (graph_model.js:323) at e.t.predict (graph_model.js:276) at HTMLImageElement.handleClick (index.js:100) t.checkInputs @ graph_executor.js:607 t.execute @ graph_executor.js:193 t.execute @ graph_model.js:323 t.predict @ graph_model.js:276 handleClick @ index.js:100

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
patlevincommented, Nov 24, 2020

@prakashr85 You are passing the wrong data into the model. The model expects a tensor but you pass it a DOM element.

The demo works, because it uses a custom model class that abstracts the input and accepts tensors as well as DOM elements:

The demo code (line 67):

model.detect(event.target).then(function (predictions) { …

Your code (line 63)

model.predict(event.target).then(function (predictions) { …

The difference might be subtle, but the TFJS model doesn’t have a detect-method - that’s a method implemented in the custom code for the model.

You can use the following code snipped to get the correct input for model.predict:

const input = tf.tidy(() => {
  const img = tf.browser.fromPixels(event.target)
  return img.expandDims(0)
})

model.predict(input).then(function(results) { ...

I doubt that would be all of the necessary changes, though, since the model will return an array of tensors that you will need to process according to the model’s architecture. Judging from the ultralytics yolo v5 source code, you will have to translate the relevant parts of yolo.py and test.py to JavaScript (or TypeScript) in order to use it in the browser.

0reactions
google-ml-butler[bot]commented, Dec 8, 2020

Are you satisfied with the resolution of your issue? Yes No

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: The shape of dict['images'] provided in model.execute ...
The error indicates that there is a mismatch between the shape defined in the model and the shaped of the input passed ...
Read more >
The shape of dict['image'] provided in model.execute(dict ...
The error is letting you know that input named image must be a scalar (shape []) instead of a 3D tensor, which is...
Read more >
Error: The shape of dict['input_tensor'] provided in model ...
Hi, I converted my saved model to model json using tensorflowjs_converter tensorflowjs_converter \ --input_format=tf_saved_model ...
Read more >
Python - Dictionary - Tutorialspoint
Keys are unique within a dictionary while values may not be. The values of a dictionary can be of any type, but the...
Read more >
Debugging errors - dbt Developer Hub
Compile the dependencies into a graph. Check that it's acyclic. Dependency Error. SQL execution, Run the models, Database Error. Let's dive into ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found