Layout-Parser / layout-parser

A Unified Toolkit for Deep Learning Based Document Image Analysis
https://layout-parser.github.io/
Apache License 2.0
4.64k stars 449 forks source link

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

Open sudoghut opened 1 year ago

sudoghut commented 1 year ago

Describe the bug When I tried the sample codes:

!pip install layoutparser
!pip install 'git+https://github.com/facebookresearch/detectron2.git@v0.4#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!