decisionforce / CoPO

[NeurIPS 2021] Official implementation of paper "Learning to Simulate Self-driven Particles System with Coordinated Policy Optimization".
Apache License 2.0
117 stars 20 forks source link

visualization problem #31

Closed Mming11 closed 9 months ago

Mming11 commented 1 year ago

When i have my checkpoint folder , how can i visualize it . When i run [vis_from_checkpoint.py] directly, there is something wrong with it .I know checkpoint need to be processed but i don not know how to do. I'm so sorry for my stupid... Hope you can give me hints in detail or examples. Thanks a lot. ToT

pengzhenghao commented 1 year ago

Please take a look on this file:

https://github.com/decisionforce/CoPO/blob/18e97ae30beccd393b580281f509d8e7ed561126/copo_code/copo/new_vis.py

We update the visualization script so that it can read RLLib checkpoints directly (without converting weight to numpy first).

Mming11 commented 1 year ago

Thank you. I'll try it this afternoon.

Mming11 commented 1 year ago

Please take a look on this file:

https://github.com/decisionforce/CoPO/blob/18e97ae30beccd393b580281f509d8e7ed561126/copo_code/copo/new_vis.py

We update the visualization script so that it can read RLLib checkpoints directly (without converting weight to numpy first).

when i run new_vis.py , i meet an error. 1 ToT

pengzhenghao commented 1 year ago

It seems that your model are trained with PyTorch and my script is meant for loading tensorflow checkpoints.

A workaround here is to replace the policy_function by the RLLib trainer.

A basic logic is:

...

trainer = PPOTrainer({some config})
trainer.restore(CHECKPOINT_FOLDER_PATH)

...

action = trainer.compute_single_action(obs)
o, r, d, i = env.step(action)

...

I admit that it is not necessary to use custom function like my script to load the trained agent. We should stick to RLLib trainer since it is more convenient.