uoe-agents / epymarl

An extension of the PyMARL codebase that includes additional algorithms and environment support
Apache License 2.0
506 stars 137 forks source link

How to load model and visualize results #30

Open darwinharianto opened 2 years ago

darwinharianto commented 2 years ago

Thank you for sharing!!

Using colored RWARE environment, I want to ask how to load and visualize trained models on colored rware

import gym

env = gym.make("rware-1color-tiny-4ag-v1", sensor_range=3, request_queue_size=6)
n_step = 1000 
model = load_something(model_path) # how do I load model?
for _ in range(n_step):
  obs = env.reset()
  actions = model.forward(obs)
  n_obs, reward, done, info = env.step(actions)
  print(f"{info=}")
  env.render()
  time.sleep(0.5)
  if (done):
    break
env.close()
Xiyou521 commented 2 years ago

I have the same question. Can someone tell me how to visualize the experimental environment? Thank you very much.

SaraRezaei commented 1 year ago

I have the same question. Can someone tell me how to visualize the experimental environment? Thank you very much.

lcdbezerra commented 1 year ago

From README:

Learnt models can be loaded using the checkpoint_path parameter, after which the learning will proceed from the corresponding timestep.

So I guess something like this: python3 src/main.py --config=mappo --env-config=gymma with env_args.key="rware-1color-tiny-4ag-v1" checkpoint_path="/PATH_TO_MODEL" You probably need to wrap the env around a render wrapper too, and make batch_run_size=1 so that you don't get multiple windows at a time.

atapley commented 1 year ago

Yeah, same question from me - I posted a similar question a few days ago before I saw this. It looks like rendering is not currently implemented for non-sc2 environments. From my search it looks like the save_reply method needs to be manually implemented or a render flag will need to be added to the config and within the runner code. Hoping I'm wrong though and there's an out-of-the-box solution that I'm just missing

abdulghani91 commented 1 year ago

I'm trying to run MAPPO or IPPO with sc2 environment but I couldn't figured out how to specify the maps. I already us pymarl and run the algorithms with this code:

python3 src/main.py --config=qmix --env-config=sc2 with env_args.map_name=2s3z

I want to run epymarl with MAPPO or IPPO algorithms with the same map 2s3z from sc2. could any one help me with that? I'm using this code:

python3.7 src/main.py --config=mappo --env-config=sc2 with env_args.time_limit=25 env_args.key="SMAC:2s3z"

I get this error:

sacred.utils.ConfigAddedError: Added new config entry that is not used anywhere Conflicting configuration values: env_args.key=SMAC:2s3z

youchenlong commented 1 year ago

python src/main.py --config=qmix --env-config=gymma with env_args.time_limit=25 env_args.key="mpe:SimpleSpeakerListener-v0" checkpoint_path="your path" evaluate=True render=True