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

[Question] cv2 error on using expert_dataset.py (follow-up from DeprecationWarning: DataPipeline.sarsd_iter) #17

Open
prabhasak opened this issue Jul 5, 2020 · 0 comments

Comments

@prabhasak
Copy link

prabhasak commented Jul 5, 2020

Hello. There is a cv2 error on running any baseline code from general/chainerrl/baselines (after fixing this issue). Here's the traceback on running the GAIL.py baseline:

Traceback (most recent call last):
  File "gail.py", line 421, in <module>
    main()
  File "gail.py", line 146, in main
    _main(args)
  File "gail.py", line 291, in _main
    shuffle=False)
  File "C:\MineRL\baselines\general\chainerrl\baselines\expert_dataset.py", line 110, in __init__
    self._convert(original_dataset)
  File "C:\MineRL\baselines\general\chainerrl\baselines\expert_dataset.py", line 120, in _convert
    obs = self.observation_converter(orig_obs)
  File "C:\MineRL\baselines\general\chainerrl\baselines\observation_wrappers.py", line 24, in converter
    cv2.cvtColor(obs, cv2.COLOR_RGB2GRAY), axis=-1)
cv2.error: OpenCV(4.3.0) c:\projects\opencv-python\opencv\modules\imgproc\src\color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function '__cdecl cv::impl::`anonymous-namespace'::CvtHelper<struct cv::impl::`anonymous namespace'::Set<3,4,-1>,struct cv::impl::A0xe227985e::Set<1,-1,-1>,struct cv::impl::A0xe227985e::Set<0,2,5>,2>::CvtHelper(const class cv::_InputArray &,const class cv::_OutputArray &,int)'
> Invalid number of channels in input image:
>     'VScn::contains(scn)'
> where
>     'scn' is 1

Exception in thread QueueManagerThread:
Traceback (most recent call last):
  File "C:\Users\prabh\Miniconda3\envs\minerlpk\lib\threading.py", line 917, in _bootstrap_inner
    self.run()
  File "C:\Users\prabh\Miniconda3\envs\minerlpk\lib\threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\prabh\Miniconda3\envs\minerlpk\lib\concurrent\futures\process.py", line 354, in _queue_management_worker
    ready = wait(readers + worker_sentinels)
  File "C:\Users\prabh\Miniconda3\envs\minerlpk\lib\multiprocessing\connection.py", line 872, in wait
    ov.cancel()
OSError: [WinError 6] The handle is invalid

Failed to delete the temporary minecraft directory.
  1. On tracing the issue, turns out what's fed into self.observation_converter() and self.action_converter() variables has shape (1, 32, 64, 64, 3) instead of (32, 64, 64, 3) (introduced from the new DataPipeline.batch_iter(**1**, 32, 1))

  2. So, in both observation_wrappers.py and action_wrappers.py we need to ignore the first dim (use dict[keys][0] instead of dict[keys]) and append the dim on return (return np.expand_dims(list, 0) instead of return list). This seems to fix the problem

Note: dict = observation, action and list = ret, val in the two files, respectively

PS: If the spaces weren't dict, we could fix this by just initializing the converters as lambda x: x[0] instead of lambda x: x :v

System Info

  • Windows 10
  • Python 3.7.0
  • Tensorflow 2.2.0
  • minerl 0.3.5
@prabhasak prabhasak changed the title [Question] DeprecationWarning: DataPipeline.sarsd_iter method is deprecated! Request for update [Question] cv2 error on using expert_dataset.py (follow-up from DeprecationWarning: DataPipeline.sarsd_iter) Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant