mmocr: Permission denied: '/mmocr/mmocr/core/font.TTF'

When I run recog-demo liked that python mmocr/utils/ocr.py %INPUT_FOLDER_PATH% --det None --recog CRNN_TPS --batch-mode --single-batch-size 10 --output %OUPUT_FOLDER_PATH%,permissionError happened.

Matplotlib created a temporary config/cache directory at /tmp/matplotlib-wz8itdit because the default path (/.config/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing. load checkpoint from local path: /gdata1/huyc/hzx/weights/sar_r31_parallel_decoder_chineseocr_20210507-b4be8214.pth /mmocr/mmocr/apis/utils.py:53: UserWarning: Remove “MultiRotateAugOCR” to support batch inference since samples_per_gpu > 1. warnings.warn(warning_msg) /mmocr/mmocr/apis/utils.py:53: UserWarning: Remove “MultiRotateAugOCR” to support batch inference since samples_per_gpu > 1. warnings.warn(warning_msg) Downloading https://download.openmmlab.com/mmocr/data/font.TTF …(because of the safe question,I can’t download it directly from the web) Traceback (most recent call last): File “/opt/conda/lib/python3.8/shutil.py”, line 788, in move os.rename(src, real_dst) PermissionError: [Errno 13] Permission denied: ‘/tmp/tmpt7zujgkl’ -> ‘/mmocr/mmocr/core/font.TTF’

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “mmocr/utils/ocr.py”, line 718, in <module> main() File “mmocr/utils/ocr.py”, line 714, in main ocr.readtext(**vars(args)) File “mmocr/utils/ocr.py”, line 438, in readtext pp_result = self.single_pp(result, model) File “mmocr/utils/ocr.py”, line 479, in single_pp res_img = model.show_result(arr, res, out_file=output) File “/mmocr/mmocr/models/textrecog/recognizer/base.py”, line 218, in show_result img = imshow_text_label( File “/mmocr/mmocr/core/visualize.py”, line 357, in imshow_text_label pred_img = draw_texts_by_pil(img, [pred_label], None) File “/mmocr/mmocr/core/visualize.py”, line 608, in draw_texts_by_pil shutil.move(local_filename, font_path) File “/opt/conda/lib/python3.8/shutil.py”, line 802, in move copy_function(src, real_dst) File “/opt/conda/lib/python3.8/shutil.py”, line 432, in copy2 copyfile(src, dst, follow_symlinks=follow_symlinks) File “/opt/conda/lib/python3.8/shutil.py”, line 261, in copyfile with open(src, ‘rb’) as fsrc, open(dst, ‘wb’) as fdst: PermissionError: [Errno 13] Permission denied: ‘/mmocr/mmocr/core/font.TTF’ I have no name!@8f2c5473204a:/ghome/mmocr-main$ Permission denied: ‘/mmocr/mmocr/core/font.TTF’ ``

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18

Most upvoted comments

It seems there are at least two MMOCR copies on your machine/container, one at /mmocr/ and another one at /ghome/huyc/hzx/mmocr-main. I guess you’re running our docker image, mounting mmocr/ in your host to /mmocr/ in your container. And you’ve cloned another mmocr to /ghome/huyc/hzx/mmocr-main, which is the directory that you are working on.

First, since the pre-installed mmocr package in this container is pointing to /mmocr/, I’d suggest you remove your clone at /ghome/huyc/hzx/mmocr-main and change your working directory to /mmocr to avoid any confusion.

As for the permission issue, you might not give enough permission to mmocr/ directory on your host machine. Try sudo chmod -R 777 PATH_TO_MMOCR on your host machine and see if you can modify the files in /mmocr/ in your container.

The path ‘/mmocr/mmocr/core/font.TTF’ is an absolute path to root. I guess it should be changed to the current mmocr path, like ‘/ghome/huyc/hzx/mmocr/core/font.TTF’.

Seems the script doesn’t have the write permission to mmocr/ folder. You can recursively relax its permission by running

sudo chmod -R 777 {path to your current folder}/mmocr

Read through the guide for more details: https://www.guru99.com/file-permissions.html