jkulhanek / robot-visual-navigation

Visual Navigation in Real-World Indoor Environments Using End-to-End Deep Reinforcement Learning Official Implementation
MIT License
58 stars 11 forks source link

render_video problem #5

Closed rokhmatf closed 2 years ago

rokhmatf commented 2 years ago

I made an issue based on answer from https://github.com/jkulhanek/robot-visual-navigation/issues/4#issuecomment-1080374996 and i still can't run command python render_video.py , my terminal output like below

/home/rokhmat/anaconda3/envs/tesis/lib/python3.8/site-packages/deep_rl/common/util.py:1: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
  from collections import OrderedDict, Callable
Registering trainer turtlebot
Registering trainer turtlebot-noprior
Registering trainer turtlebot-unreal
Registering trainer turtlebot-unreal-noprior
Registering trainer turtlebot-a2c
Registering trainer turtlebot-a2c-noprior
Registering trainer dmhouse-a2c
Registering trainer dmhouse-unreal
Registering trainer dmhouse-ppo
Registering trainer dmhouse-ppo-a2cvn
Registering trainer turtlebot-ppo-a2cvn
Registering trainer dmhouse-ppo-unreal
Registering trainer dmhouse-dqn
Registering agent dmhouse-dqn
Registering trainer dmhouse
Registering agent turtlebot-noprior
Registering agent turtlebot
Registering agent dmhouse
Registering agent dmhouse-a2c
Registering agent dmhouse-ppo
Registering agent dmhouse-unreal
Registering agent turtlebot-a2c
Registering agent turtlebot-unreal
Registering agent turtlebot-a2c-noprior
Registering agent turtlebot-unreal-noprior
Traceback (most recent call last):
  File "render_video.py", line 76, in <module>
    env = trainer.create_envs(1, dict(renderer="hardware", screen_size=(500, 500), **default_args()['env_kwargs']),
  File "/home/rokhmat/tesis/robot-visual-navigation/python/trainer.py", line 550, in create_envs
    env = create_multiscene(num_training_processes, wrap=wrap_internal, use_dummy=use_dummy, **env_kwargs)
  File "/home/rokhmat/tesis/robot-visual-navigation/python/environment/__init__.py", line 58, in create_multiscene
    return AsyncVectorEnv(funcs)
  File "/home/rokhmat/anaconda3/envs/tesis/lib/python3.8/site-packages/gym/vector/async_vector_env.py", line 128, in __init__
    dummy_env = env_fns[0]()
  File "/home/rokhmat/tesis/robot-visual-navigation/python/environment/__init__.py", line 49, in func
    env = wrap(gym.make(**kwargs))
  File "/home/rokhmat/anaconda3/envs/tesis/lib/python3.8/site-packages/gym/envs/registration.py", line 676, in make
    return registry.make(id, **kwargs)
  File "/home/rokhmat/anaconda3/envs/tesis/lib/python3.8/site-packages/gym/envs/registration.py", line 520, in make
    return spec.make(**kwargs)
  File "/home/rokhmat/anaconda3/envs/tesis/lib/python3.8/site-packages/gym/envs/registration.py", line 137, in make
    env = self.entry_point(**_kwargs)
  File "/home/rokhmat/tesis/robot-visual-navigation/python/environment/__init__.py", line 12, in _createImageEnvironment
    return ImageEnvironmentWrapper(TimeLimit(ImageEnvironment(**kwargs), 300))
  File "/home/rokhmat/tesis/robot-visual-navigation/python/environment/image_collection_environment.py", line 45, in __init__
    super(ImageEnvironment, self).__init__(**kwargs)
TypeError: object.__init__() takes exactly one argument (the instance to initialize)

is there something missing from the command I ran? or are there steps i have to do? Previously I have downloaded the pre-trained models that you provide. Thanks for your attention. I’m looking forward to your reply.

jkulhanek commented 2 years ago

It should be working now. I tested it with the dmhouse environment.

rokhmatf commented 2 years ago

after I run the command python render_video.py --path /home/rokhmat/thesis/robot-visual-navigation dmhouse, there is an error as below:

(robotvn) rokhmat@b401:~/tesis/robot-visual-navigation/python$ python render_video.py --path /home/rokhmat/tesis/robot-visual-navigation dmhouse
Traceback (most recent call last):
  File "render_video.py", line 1, in <module>
    import gym
  File "/home/rokhmat/anaconda3/envs/robotvn/lib/python3.8/site-packages/gym/__init__.py", line 4, in <module>
    from gym.core import (
  File "/home/rokhmat/anaconda3/envs/robotvn/lib/python3.8/site-packages/gym/core.py", line 7, in <module>
    from gym import spaces
  File "/home/rokhmat/anaconda3/envs/robotvn/lib/python3.8/site-packages/gym/spaces/__init__.py", line 1, in <module>
    from gym.spaces.space import Space
  File "/home/rokhmat/anaconda3/envs/robotvn/lib/python3.8/site-packages/gym/spaces/space.py", line 15, in <module>
    from gym.utils import seeding
  File "/home/rokhmat/anaconda3/envs/robotvn/lib/python3.8/site-packages/gym/utils/seeding.py", line 7, in <module>
    from numpy.random import Generator
ImportError: cannot import name 'Generator' from 'numpy.random' (/home/rokhmat/anaconda3/envs/robotvn/lib/python3.8/site-packages/numpy/random/__init__.py)

there seems to be a problem with the gym version, should I change to an older version?

jkulhanek commented 2 years ago

This is a wrong numpy version. If you start with a fresh environment and install all requirements.txt you should not have this problem.

rokhmatf commented 2 years ago

I have started with a new environment and installed all the requirements.txt, but I got an error with cv2

(robotvn) rokhmat@b401:~/tesis/robot-visual-navigation/python$ python render_video.py --path=/home/rokhmat/tesis/robot-visual-navigation dmhouse
Traceback (most recent call last):
  File "render_video.py", line 4, in <module>
    import cv2
ModuleNotFoundError: No module named 'cv2'

so I installed cv2 by conda install -c conda-forge opencv -y,but after successfully installing cv2 (opencv 4.5.4), there was an error like yesterday

(robotvn) rokhmat@b401:~/tesis/robot-visual-navigation/python$ python render_video.py --path=/home/rokhmat/tesis/robot-visual-navigation dmhouse
Traceback (most recent call last):
  File "render_video.py", line 1, in <module>
    import gym
  File "/home/rokhmat/anaconda3/envs/robotvn/lib/python3.8/site-packages/gym/__init__.py", line 4, in <module>
    from gym.core import (
  File "/home/rokhmat/anaconda3/envs/robotvn/lib/python3.8/site-packages/gym/core.py", line 7, in <module>
    from gym import spaces
  File "/home/rokhmat/anaconda3/envs/robotvn/lib/python3.8/site-packages/gym/spaces/__init__.py", line 1, in <module>
    from gym.spaces.space import Space
  File "/home/rokhmat/anaconda3/envs/robotvn/lib/python3.8/site-packages/gym/spaces/space.py", line 15, in <module>
    from gym.utils import seeding
  File "/home/rokhmat/anaconda3/envs/robotvn/lib/python3.8/site-packages/gym/utils/seeding.py", line 7, in <module>
    from numpy.random import Generator
ImportError: cannot import name 'Generator' from 'numpy.random' (/home/rokhmat/anaconda3/envs/robotvn/lib/python3.8/site-packages/numpy/random/__init__.py)
rokhmatf commented 2 years ago

I have found the problem, i tried using opencv with an previous version (4.5.2) and in my case it worked. I installed opencv by pip install opencv-python==4.5.2.*

then run the command to render the video and produce the terminal output as below

(try-robotvn) rokhmat@b401:~/zzz-test/robot-visual-navigation/python$ python render_video.py --path=/home/rokhmat/zzz-test/robot-visual-navigation dmhouse
/home/rokhmat/anaconda3/envs/try-robotvn/lib/python3.8/site-packages/deep_rl/common/util.py:1: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
  from collections import OrderedDict, Callable
Registering trainer turtlebot
Registering trainer turtlebot-noprior
Registering trainer turtlebot-unreal
Registering trainer turtlebot-unreal-noprior
Registering trainer turtlebot-a2c
Registering trainer turtlebot-a2c-noprior
Registering trainer dmhouse-a2c
Registering trainer dmhouse-unreal
Registering trainer dmhouse-ppo
Registering trainer dmhouse-ppo-a2cvn
Registering trainer turtlebot-ppo-a2cvn
Registering trainer dmhouse-ppo-unreal
Registering trainer dmhouse-dqn
Registering agent dmhouse-dqn
Registering trainer dmhouse
Registering agent turtlebot-noprior
Registering agent turtlebot
Registering agent dmhouse
Registering agent dmhouse-a2c
Registering agent dmhouse-ppo
Registering agent dmhouse-unreal
Registering agent turtlebot-a2c
Registering agent turtlebot-unreal
Registering agent turtlebot-a2c-noprior
Registering agent turtlebot-unreal-noprior
/home/rokhmat/anaconda3/envs/try-robotvn/lib/python3.8/site-packages/dmhouse/__init__.py:3: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp

but the resulting video has a low resolution, can I produce a video with a higher resolution?

jkulhanek commented 2 years ago

Sorry, currently I don't have the capacity to write the wrapper to render video in higher res. But you can easily do it yourself and I will be happy to accept the PR. In order to do that, you can implement a wrapper that will construct the inner env with higher res and store and downsample the observations.

rokhmatf commented 2 years ago

I've found a way to get better rendering results, I was inspired by the colab you provided. basically I just increase the plot size and save the animation with better quality. I think the results are quite satisfactory. thank you very much.