-
Notifications
You must be signed in to change notification settings - Fork 33
Description
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.
-
On tracing the issue, turns out what's fed into
self.observation_converter()andself.action_converter()variables has shape(1, 32, 64, 64, 3)instead of(32, 64, 64, 3)(introduced from the newDataPipeline.batch_iter(**1**, 32, 1)) -
So, in both
observation_wrappers.pyandaction_wrappers.pywe need to ignore the first dim (usedict[keys][0]instead ofdict[keys]) and append the dim on return (return np.expand_dims(list, 0)instead ofreturn 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