Unable to cast Python instance to C++ type (Trying to script Yolov3)

I’m trying to use torch.jit.script to script a modified version of ultralytics yolov3
I’ve modified it a bit to fix all kinds of errors during the scripting process and now I’m getting

  File "C:\ProgramData\Anaconda3\envs\yolo_pytorch\lib\site-packages\torch\jit\_recursive.py", line 325, in init_fn
    cpp_module.setattr(name, orig_value)
RuntimeError: Unable to cast Python instance to C++ type (compile in debug mode for details)

It happens when trying to set the attribute for the module_def, which is of type List[Dict[str, str]]
I’ve modified the module_defs for all the keys & values to be strings

I’m using torch 1.5.0 on Windows 10 64 bit

Any suggestions on how to tackle this? if more info is needed, let me know what

I would generally recommend to update to the latest stable version, as a lot was fixes/added into the JIT.

I will try with 1.7.0 and will update

The problem still happened in 1.7.0, but then I iterated the list and found that in some cases, one of the values was initialized as int(0). I changed that to "0" and it worked