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

Is there some way to surpress this warning message? #5349

Closed
TylerLeonhardt opened this issue Jul 19, 2021 · 8 comments · Fixed by #5368
Closed

Is there some way to surpress this warning message? #5349

TylerLeonhardt opened this issue Jul 19, 2021 · 8 comments · Fixed by #5368
Assignees
Labels
type:feature New feature or request

Comments

@TylerLeonhardt
Copy link

Please make sure that this is a feature request. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:feature_template

System information

  • TensorFlow.js version (you are using): 3.8.0
  • Are you willing to contribute it (Yes/No): maybe but likely no

Describe the feature and the current behavior/state.

👋 from the VS Code team

We use tfjs in VS Code and see this warning:
image

It would add a lot of extra complexity to include tfjs-node in VS Code so we'd like to not do what it's suggesting and instead would like to suppress this warning.

Is this possible?

Will this change the current api? How?
No

Who will benefit with this feature?
People who don't want to use tfjs-node

Any Other info.

@TylerLeonhardt TylerLeonhardt added the type:feature New feature or request label Jul 19, 2021
@TylerLeonhardt
Copy link
Author

The 1st warning is also a little strange... it's something inside of tfjs causing that.

@pyu10055
Copy link
Collaborator

@TylerLeonhardt what environment are you running in? seems both of the flags IS_BROWSER and IS_NODE are true.

export function isBrowser(): boolean {
  return (typeof window !== 'undefined' && window.document != null) ||
      //@ts-ignore
      (typeof WorkerGlobalScope !== 'undefined');
}

/** Whether we are in a browser (as versus, say, node.js) environment. */
ENV.registerFlag(
    'IS_NODE',
    () => (typeof process !== 'undefined') &&
        (typeof process.versions !== 'undefined') &&
        (typeof process.versions.node !== 'undefined'));

@TylerLeonhardt
Copy link
Author

TylerLeonhardt commented Jul 20, 2021

@pyu10055 within VS Code. My guess is that since it's an electron app... both return true.
image

You can test this by opening up the dev tools in VS Code:

  • Open the command palette and type: Dev Tools
  • then choose this one:
    image

@pyu10055
Copy link
Collaborator

pyu10055 commented Jul 20, 2021

@TylerLeonhardt in this case, you can just use webgl backend by not including tfjs-backend-cpu package.
in you deps, you can add only tfjs-core, tfjs-backend-webgl, tfjs-converter packages instead of tfjs union package.
Or if you prefer cpu backend, you can swap webgl dep with cpu in above list.

@TylerLeonhardt
Copy link
Author

@pyu10055 thanks for the pointer! I believe you said CPU is best in our use-case in the previous issue, so I'm trying that.
Here's what I tried:

  • Removing @tensorflow/tfjs from package.json
  • Adding these to package.json:
    • "@tensorflow/tfjs-backend-cpu": "^3.8.0",
    • "@tensorflow/tfjs-converter": "^3.8.0",
    • "@tensorflow/tfjs-core": "^3.8.0",
  • Changing this:
import { GraphModel, io, loadGraphModel, Rank, setBackend, tensor, Tensor } from '@tensorflow/tfjs';

to

import { Rank, tensor, Tensor, io, setBackend } from '@tensorflow/tfjs-core';
import { GraphModel, loadGraphModel } from '@tensorflow/tfjs-converter';
import '@tensorflow/tf-backend-cpu';

Unfortunately, this still yields the logs in the original screenshot.

For your reference, the code in question is found here: https://github.com/Microsoft/vscode-languagedetection
and is then loaded into vscode. The test in the vscode-languagedetection repo shows the "hi there 👋 " log.

@pyu10055
Copy link
Collaborator

@TylerLeonhardt can you try to set IS_NODE to false before you load the model?

tf.env().set('IS_NODE', false);

@TylerLeonhardt
Copy link
Author

@pyu10055 That gets rid of the "hi there 👋 " log, great!

The last one that shows up is:

Platform browser has already been set. Overwriting the platform with [object Object].

which only shows up when running in VS Code... (in electron, I guess)... in my mocha tests in the vscode-languagedetection repo I do not see it.

@TylerLeonhardt
Copy link
Author

Thanks for this @pyu10055!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants