layout-parser icon indicating copy to clipboard operation
layout-parser copied to clipboard

cannot import name 'is_directory' from 'PIL._util'(lp.Detectron2LayoutModel)

Open sudoghut opened this issue 3 years ago • 0 comments

Describe the bug When I tried the sample codes:

!pip install layoutparser
!pip install 'git+https://github.com/facebookresearch/[email protected]#egg=detectron2'

import layoutparser as lp
import cv2
import PIL

image = cv2.imread("image.png")
model = lp.Detectron2LayoutModel('lp://PubLayNet/faster_rcnn_R_50_FPN_3x/config')
layout = model.detect(image)

Colab link(Python 3.8.16): https://colab.research.google.com/drive/1lb8_Pcw8_NNdeKPL80HOYca8gaCB0f-E?usp=sharing

I got an error on this line:

lp.Detectron2LayoutModel('lp://PubLayNet/faster_rcnn_R_50_FPN_3x/config')

The error message is:

ImportError: cannot import name 'is_directory' from 'PIL._util' (/usr/local/lib/python3.8/dist-packages/PIL/_util.py)

I hope that I can get your help. Thanks!

sudoghut avatar Dec 13 '22 01:12 sudoghut