Giter Site home page Giter Site logo

Video recording about slm-lab HOT 8 OPEN

kengz avatar kengz commented on May 21, 2024
Video recording

from slm-lab.

Comments (8)

kengz avatar kengz commented on May 21, 2024

Hi, the lab does not have this capability now, contributions are certainly welcome! If you'd like to work on it, I'd suggest a minimal method insertion like the one done for rendering here, just to ensure API consistency and simplicity.

from slm-lab.

colllin avatar colllin commented on May 21, 2024

I was able to get it working — the commit is here: colllin@b7d70cd

Example usage:

$ RECORD=true python run_lab.py data/dqn_cartpole_2019_123/dqn_cartpole_spec.json dqn_cartpole enjoy@dqn_cartpole_t0_s0_ckpt-best

I have some open questions that prevent me from submitting as a PR:

  • I can’t get the “enjoy” mode to work. I get an error about eval_df being empty. Should “enjoy” be able to read the eval_df from the data? That doesn’t seem to be working right now, or I’m doing it wrong. I commented out a few lines while I was testing the video recording.
  • Do you have a script or procedure for testing changes across environments? I should test video recording on vector envs and unity envs. I have no idea if the gym.wrappers.Monitor will work universally across envs.

Alternatively, if the integration is too complex, we could close this issue and you could point other people here to merge my commit into their project if they want to record video.

Thank you for your help & attention!

from slm-lab.

kengz avatar kengz commented on May 21, 2024

Hey, this looks good! It is also simple enough to integrate nicely in. We'd be more than happy to accept a PR; this will be a wonderful addition to the lab.

The enjoy mode thing is probably complaining about a specific eval_frequency. If you run say 10000 max_frame and set eval_frequency to 1000, it will have populated the eval_df with 10 rows. If something else is causing that issue, I can take a look at the CI test and help fix the error.

That said, it suffices to test just on a gym environment now since unity tests are mostly excluded. Most tests are located in test files while directly mirror the original file structure. Feel free to add just 1 simple test.

from slm-lab.

colllin avatar colllin commented on May 21, 2024

Thanks @kengz, I’d be happy to write a test, add some docs, and submit a PR. Can you help me with something though? When I run the following commands (basically right out of the docs), enjoy mode seems to fail for me:

$ python run_lab.py slm_lab/spec/demo.json dqn_cartpole train
...
$ python run_lab.py data/dqn_cartpole_2019_.../dqn_cartpole_spec.json dqn_cartpole enjoy@dqn_cartpole_t0_s1
Traceback (most recent call last):                                                                                                                                                                 
  File "run_lab.py", line 84, in <module>                                                                                                                                                          
    main()                                                                                                                                                                                         
  File "run_lab.py", line 73, in main                                                                                                                                                              
    read_spec_and_run(*args)                                                                                                                                                                       
  File "run_lab.py", line 57, in read_spec_and_run                                                                                                                                                 
    run_spec(spec, lab_mode)                                                                                                                                                                       
  File "run_lab.py", line 42, in run_spec                                                                                                                                                          
    Session(spec).run()                                                                                                                                                                            
  File "/home/ubuntu/SLM-Lab/slm_lab/experiment/control.py", line 115, in run                                                                                                                      
    metrics = analysis.analyze_session(self.spec, self.agent.body.eval_df, 'eval')                                                                                                                 
  File "/home/ubuntu/SLM-Lab/slm_lab/experiment/analysis.py", line 232, in analyze_session                                                                                                         
    assert len(session_df) > 1, f'Need more than 1 datapoint to calculate metrics'                                                                                                                 
AssertionError: Need more than 1 datapoint to calculate metrics 

Am I missing something? It seems that self.agent.body.eval_df hasn’t been populated as expected.

from slm-lab.

kengz avatar kengz commented on May 21, 2024

Hey, pretty sure you added code is not causing that since it doesnt have any side effects.
Could u double check that you're on the latest commit? git log would show the latest SHA starting with 89edebc
I suspect your demo.json has an eval_frequency that is too big so it never got to collect that many eval checkpoint data rows.

from slm-lab.

kengz avatar kengz commented on May 21, 2024

hi @colllin are you still facing the issue?

from slm-lab.

colllin avatar colllin commented on May 21, 2024

from slm-lab.

kengz avatar kengz commented on May 21, 2024

test it under the module of that added method; doing so might be cleaner. Just get an test_env from the conf test to get an example environment and step it through with random action as done here

while not done:
_, reward, done, _ = env.step(env.action_space.sample())

however, if it's problematic, just add a minimal invocation test or no test, since the addition is short.

from slm-lab.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.