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

config.js file changes are not reflected in the gui #19

Closed
delebash opened this issue Nov 4, 2020 · 16 comments
Closed

config.js file changes are not reflected in the gui #19

delebash opened this issue Nov 4, 2020 · 16 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@delebash
Copy link

delebash commented Nov 4, 2020

Tested demo folder index.html using only hand pose enabled

  1. Open config.js
  2. Change hand>maxHands: to 1
  3. Launch index.html and the gui still has Max Objects set to 10
    I also tested another variable by setting backend to wasm but the change was also not updated in the gui
@vladmandic
Copy link
Owner

vladmandic commented Nov 4, 2020

demo has default configuration overrides set in demo/browser.js:config - simply for purpose of having a local variable so menu can bind something to directly

if those are removed, then defaults from config.js are used

how it works is that any override is deep-merged with values from config.js

@vladmandic vladmandic self-assigned this Nov 4, 2020
@vladmandic vladmandic added the documentation Improvements or additions to documentation label Nov 4, 2020
@delebash
Copy link
Author

delebash commented Nov 4, 2020

Great thanks for the explanation

@delebash delebash closed this as completed Nov 4, 2020
@delebash delebash reopened this Nov 4, 2020
@delebash
Copy link
Author

delebash commented Nov 4, 2020

Did not mean to close since this is outstanding :)

@vladmandic
Copy link
Owner

i've updated the docs, will be up in the next publish, it's ok to close now.

@delebash
Copy link
Author

delebash commented Nov 7, 2020

I still do not see any changes in the gui after changing config.js. Per your comment I do not see a config object in browser.js. I do see variables in the setupMenu function as menu.addBool('Face Detect', human.config.face, 'enabled');. My expectation would be that the gui would reflect the changes made in config.js so if I have in my config
face: {
enabled: false
}

Than the gui slider FACE DETECT would load as disabled. Am I doing something wrong?

@delebash
Copy link
Author

delebash commented Nov 7, 2020

Off Topic:

When I push commit's to my fork do you get notified on github. The reason I am asking is that I don't want to bother you when I am making changes to my fork.

@vladmandic
Copy link
Owner

vladmandic commented Nov 7, 2020

i removed config object from browser.js earlier today, demo should now link directly to config from main library, meaning config.js.

but if you change anything in config.js directly, you do need to do a library rebuild, either using npm run rebuild or use dev-server i wrote yesterday, npm run dev

and no, i don't get notifications for separate forks.

@delebash
Copy link
Author

delebash commented Nov 8, 2020

npm run rebuild is not a valid script. Did you mean npm rebuild? Also is there a way to use the config without running npm rebuild? I am using the demo/browser.js not the dist/demo-browser-index.js

@vladmandic
Copy link
Owner

it's npm run build (sorry, my typo)
and no, config.js is included in human.js (esm/node/whatever) library, so library needs to be rebuild before it's even exposed to client.

@vladmandic
Copy link
Owner

you could import config.js into your app directly and then use human with your version passing it as override.
something like

const myConfig = require('config.js).default;
human.detect(image, myconfig);

(or equivalent import statement if you're using esm and not node)

@delebash
Copy link
Author

delebash commented Nov 8, 2020

Thanks it works as expected. Suggestion would it not be better to just have a config.json file that can be loaded at runtime? I am testing the demo and in my case I only want the hand enabled when I open the page and everything else disabled. I also may want to start it with hand and face enabled but then I have to rebuild. I am running this in an IDE that has its own web server and importing browser.js so I don't actually need to build anything unless I change human.js I can just refresh the page.

By the way human is awesome thank you very very much for the hard work!!!

@delebash
Copy link
Author

delebash commented Nov 8, 2020

Ok importing config.js works fine for me. Thanks.

@vladmandic
Copy link
Owner

vladmandic commented Nov 8, 2020

that's the whole points of having second param to human.load() or human.detect() - to pass user configuration.
then it's merged with defaults that come from config.js.

why is config.js linked into human during build to start with? because i want it have sane default values in case something in user config is missing or invalid.

user configuration can be single flag or entire config or anything in-between. and no harm if user config is entire config.js as it's just going to be merged into single object anyhow.

and yes, it can be a json or js as well.

@delebash
Copy link
Author

delebash commented Nov 8, 2020

I understand about the defaults and overriding. I have tried the override and it does not seem to be working

browser.js

import myConfig from './config.js'

function main ....
console.log(myConfig.backend) // = webgl
await human.detect(warmup, myConfig);

No change in gui sliders

@vladmandic
Copy link
Owner

in demo, setupMenu() is called before human.load() or human.detect(), so it menu binds to default values - your values have not yet been merged at that time.
if you want to directly bind menu to your values regardless, change setupMenu parameters to use your object instead of human.config.

@delebash
Copy link
Author

delebash commented Nov 8, 2020

Works perfectly.

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

No branches or pull requests

2 participants