Search Unity

Cannot identify image file when running

Discussion in 'ML-Agents' started by InfinityGameDev, Jun 5, 2021.

  1. InfinityGameDev

    InfinityGameDev

    Joined:
    Jun 28, 2016
    Posts:
    54
    I've recently been running into this error and I'm not sure why. I tried making a new venv but it didn't seem to work. I'm using Unity 2020.3.6 and mlagents 1.9.0 preview. I was able to train for a while, but now this is happening. I'm using MBaske's Grid Sensor, but I'm not sure why that would cause this issue. It seems like a version problem to me. I was hoping someone could help! Thanks :)

    Code (CSharp):
    1. [ERROR] UnityEnvironment worker 0: environment raised an unexpected exception.
    2. Traceback (most recent call last):
    3.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents\trainers\subprocess_env_manager.py", line 208, in worker
    4.     env.reset()
    5.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents_envs\environment.py", line 310, in reset
    6.     self._update_state(rl_output)
    7.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents_envs\environment.py", line 291, in _update_state
    8.     self._env_state[brain_name] = steps_from_proto(
    9.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents_envs\timers.py", line 305, in wrapped
    10.     return func(*args, **kwargs)
    11.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents_envs\rpc_utils.py", line 330, in steps_from_proto
    12.     _process_maybe_compressed_observation(
    13.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents_envs\timers.py", line 305, in wrapped
    14.     return func(*args, **kwargs)
    15.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents_envs\rpc_utils.py", line 257, in _process_maybe_compressed_observation
    16.     batched_visual = [
    17.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents_envs\rpc_utils.py", line 258, in <listcomp>
    18.     _observation_to_np_array(agent_obs.observations[obs_index], shape)
    19.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents_envs\timers.py", line 305, in wrapped
    20.     return func(*args, **kwargs)
    21.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents_envs\rpc_utils.py", line 234, in _observation_to_np_array
    22.     img = process_pixels(
    23.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents_envs\timers.py", line 305, in wrapped
    24.     return func(*args, **kwargs)
    25.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents_envs\rpc_utils.py", line 122, in process_pixels
    26.     image = Image.open(image_fp)
    27.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\PIL\Image.py", line 2967, in open
    28.     raise UnidentifiedImageError(
    29. PIL.UnidentifiedImageError: cannot identify image file <mlagents_envs.rpc_utils.OffsetBytesIO object at 0x00000250E589F460>
    30. Traceback (most recent call last):
    31.   File "C:\Users\19198\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    32.     return _run_code(code, main_globals, None,
    33.   File "C:\Users\19198\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    34.     exec(code, run_globals)
    35.   File "C:\Users\19198\Downloads\Space\venv2\Scripts\mlagents-learn.exe\__main__.py", line 7, in <module>
    36.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents\trainers\learn.py", line 250, in main
    37.     run_cli(parse_command_line())
    38.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents\trainers\learn.py", line 246, in run_cli
    39.     run_training(run_seed, options)
    40.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents\trainers\learn.py", line 125, in run_training
    41.     tc.start_learning(env_manager)
    42.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents_envs\timers.py", line 305, in wrapped
    43.     return func(*args, **kwargs)
    44.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents\trainers\trainer_controller.py", line 173, in start_learning
    45.     self._reset_env(env_manager)
    46.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents_envs\timers.py", line 305, in wrapped
    47.     return func(*args, **kwargs)
    48.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents\trainers\trainer_controller.py", line 105, in _reset_env
    49.     env_manager.reset(config=new_config)
    50.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents\trainers\env_manager.py", line 68, in reset
    51.     self.first_step_infos = self._reset_env(config)
    52.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents\trainers\subprocess_env_manager.py", line 333, in _reset_env
    53.     ew.previous_step = EnvironmentStep(ew.recv().payload, ew.worker_id, {}, {})
    54.   File "c:\users\19198\downloads\space\venv2\lib\site-packages\mlagents\trainers\subprocess_env_manager.py", line 98, in recv
    55.     raise env_exception
    56. PIL.UnidentifiedImageError: cannot identify image file <mlagents_envs.rpc_utils.OffsetBytesIO object at 0x00000250E589F460>
     
  2. mbaske

    mbaske

    Joined:
    Dec 31, 2017
    Posts:
    473
    Hi @insane245, I can't tell from the log if the issue is related to my sensor, but it might be. Could you provide more details about your project? If you're ok with posting it on github, I'll take a look.
     
  3. InfinityGameDev

    InfinityGameDev

    Joined:
    Jun 28, 2016
    Posts:
    54
    Hi @mbaske thanks for the help! I went back and tried to fix it myself and for some reason it started working. But whenever I changed the settings back to find the problem it didn't break. So it works for now haha. If I end up figuring it out I'll post back!