Jupyter Notebook training is giving " SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated " #9490
Unanswered
AbdulAhad10
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello All,
I am trying to train on my custom dataset. The training works fine when I the code on Google Colab but it keeps on giving the SyntaxError: (Unicode error) when I am trying to run the code on my local system with Jupyter Notebook.
The mask_rcnn_r50_caffe_fpn_mstrain-poly_1x_balloon.py file looks something like this.
I have given the path to my COCO format dataset images and json file.
Modify dataset-related settings
data = dict(
train=dict(
img_prefix=r"C:\Users\AbdulAhad\Downloads\project-113-at-2022-11-28-16-05-66835454\images",
classes=classes,
ann_file=r"C:\Users\AbdulAhad\Downloads\project-113-at-2022-11-28-16-05-66835454\result.json"),
val=dict(
img_prefix=r"C:\Users\AbdulAhad\Downloads\project-113-at-2022-11-28-16-05-66835454\images",
classes=classes,
ann_file=r"C:\Users\AbdulAhad\Downloads\project-113-at-2022-11-28-16-05-66835454\result.json"),
test=dict(
img_prefix=r"C:\Users\AbdulAhad\Downloads\project-113-at-2022-11-28-16-05-66835454\images",
classes=classes,
ann_file=r"C:\Users\AbdulAhad\Downloads\project-113-at-2022-11-28-16-05-66835454\result.json"))
The error that is being given on Jupyter Notebook is -
C:\Users\AbdulAhad\anaconda3\envs\image_segmentation_mmdetection\lib\site-packages\mmcv_init_.py:20: UserWarning: On January 1, 2023, MMCV will release v2.0.0, in which it will remove components related to the training process and add a data transformation module. In addition, it will rename the package names mmcv to mmcv-lite and mmcv-full to mmcv. See https://github.com/open-mmlab/mmcv/blob/master/docs/en/compatibility.md for more details.
warnings.warn(
c:\users\abdulahad\mmdetection\mmdetection\mmdet\utils\setup_env.py:38: UserWarning: Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed.
warnings.warn(
c:\users\abdulahad\mmdetection\mmdetection\mmdet\utils\setup_env.py:48: UserWarning: Setting MKL_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed.
warnings.warn(
Traceback (most recent call last):
File "C:\Users\AbdulAhad\anaconda3\envs\image_segmentation_mmdetection\lib\site-packages\yapf\yapflib\verifier.py", line 43, in VerifyCode
compile(textwrap.dedent(code).encode('UTF-8'), '', 'exec')
File "", line 8
'C:\Users\AbdulAhad\Downloads\project-113-at-2022-11-28-16-05-66835454\result.json',
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\AbdulAhad\anaconda3\envs\image_segmentation_mmdetection\lib\site-packages\yapf\yapflib\verifier.py", line 46, in VerifyCode
ast.parse(textwrap.dedent(code.lstrip('\n')).lstrip(), '', 'exec')
File "C:\Users\AbdulAhad\anaconda3\envs\image_segmentation_mmdetection\lib\ast.py", line 50, in parse
return compile(source, filename, mode, flags,
File "", line 7
'C:\Users\AbdulAhad\Downloads\project-113-at-2022-11-28-16-05-66835454\result.json',
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\AbdulAhad\anaconda3\envs\image_segmentation_mmdetection\lib\site-packages\yapf\yapflib\verifier.py", line 50, in VerifyCode
compile(normalized_code.encode('UTF-8'), '', 'exec')
File "", line 7
'C:\Users\AbdulAhad\Downloads\project-113-at-2022-11-28-16-05-66835454\result.json',
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\AbdulAhad\mmdetection\mmdetection\tools\train.py", line 244, in
main()
File "C:\Users\AbdulAhad\mmdetection\mmdetection\tools\train.py", line 180, in main
cfg.dump(osp.join(cfg.work_dir, osp.basename(args.config)))
File "C:\Users\AbdulAhad\anaconda3\envs\image_segmentation_mmdetection\lib\site-packages\mmcv\utils\config.py", line 596, in dump
f.write(self.pretty_text)
File "C:\Users\AbdulAhad\anaconda3\envs\image_segmentation_mmdetection\lib\site-packages\mmcv\utils\config.py", line 508, in pretty_text
text, _ = FormatCode(text, style_config=yapf_style, verify=True)
File "C:\Users\AbdulAhad\anaconda3\envs\image_segmentation_mmdetection\lib\site-packages\yapf\yapflib\yapf_api.py", line 188, in FormatCode
reformatted_source = FormatTree(
File "C:\Users\AbdulAhad\anaconda3\envs\image_segmentation_mmdetection\lib\site-packages\yapf\yapflib\yapf_api.py", line 151, in FormatTree
return reformatter.Reformat(_SplitSemicolons(llines), verify, lines)
File "C:\Users\AbdulAhad\anaconda3\envs\image_segmentation_mmdetection\lib\site-packages\yapf\yapflib\reformatter.py", line 105, in Reformat
return _FormatFinalLines(final_lines, verify)
File "C:\Users\AbdulAhad\anaconda3\envs\image_segmentation_mmdetection\lib\site-packages\yapf\yapflib\reformatter.py", line 413, in _FormatFinalLines
verifier.VerifyCode(formatted_code[-1])
File "C:\Users\AbdulAhad\anaconda3\envs\image_segmentation_mmdetection\lib\site-packages\yapf\yapflib\verifier.py", line 52, in VerifyCode
raise InternalError(sys.exc_info()[1])
yapf.yapflib.verifier.InternalError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape (, line 7)
The solution that I have tried so far -
Double Backslash in the path
Raw String (r) in front of the path
But both didn't work
Environment
sys.platform: win32
Python: 3.10.8 | packaged by conda-forge | (main, Nov 4 2022, 13:42:51) [MSC v.1916 64 bit (AMD64)]
CUDA available: True
GPU 0: NVIDIA GeForce GTX 1660 Ti
CUDA_HOME: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6
NVCC: Cuda compilation tools, release 11.6, V11.6.55
MSVC: Microsoft (R) C/C++ Optimizing Compiler Version 19.34.31935 for x64
GCC: n/a
PyTorch: 1.13.0
PyTorch compiling details: PyTorch built with:
C++ Version: 199711
MSVC 192829337
Intel(R) Math Kernel Library Version 2020.0.2 Product Build 20200624 for Intel(R) 64 architecture applications
Intel(R) MKL-DNN v2.6.0 (Git Hash 52b5f107dd9cf10910aaa19cb47f3abf9b349815)
OpenMP 2019
LAPACK is enabled (usually provided by MKL)
CPU capability usage: AVX2
CUDA Runtime 11.6
NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_37,code=compute_37
CuDNN 8.3.2 (built against CUDA 11.5)
Magma 2.5.4
Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.6, CUDNN_VERSION=8.3.2, CXX_COMPILER=C:/cb/pytorch_1000000000000/work/tmp_bin/sccache-cl.exe, CXX_FLAGS=/DWIN32 /D_WINDOWS /GR /EHsc /w /bigobj -DUSE_PTHREADPOOL -openmp:experimental -IC:/cb/pytorch_1000000000000/work/mkl/include -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DUSE_FBGEMM -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.13.0, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=OFF, USE_OPENMP=ON, USE_ROCM=OFF,
TorchVision: 0.14.0
OpenCV: 4.6.0
MMCV: 1.7.0
MMCV Compiler: MSVC 192930137
MMCV CUDA Compiler: 11.6
MMDetection: 2.25.3+
Additional information
The dataset that I am using is in COCO format and the annotation tool that I used is Label-Studio for annotating the image dataset.
Note
The same training file with same annotation file and images work completely fine on Google Colab.
Please suggest me a solution for this.
Beta Was this translation helpful? Give feedback.
All reactions