Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'PIL.Image' has no attribute 'LINEAR' #187

Open
Aman-Preet-Singh-Gulati opened this issue Jul 24, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@Aman-Preet-Singh-Gulati

Code:
import layoutparser as lp
model = lp.Detectron2LayoutModel(
config_path ='lp://MFD/faster_rcnn_R_50_FPN_3x/config', # In model catalog
label_map ={0: "Text", 1: "Title", 2: "List", 3:"Table", 4:"Figure"}, # In modellabel_map
extra_config=["MODEL.ROI_HEADS.SCORE_THRESH_TEST", 0.7] # Optional
)
layout = model.detect(image) # You need to load the image somewhere else, e.g., image = cv2.imread(...)
lp.draw_box(image, layout, box_width=5, show_element_type=True)

Error:

AttributeError Traceback (most recent call last)

in <cell line: 2>()
1 import layoutparser as lp
----> 2 model = lp.Detectron2LayoutModel(
3 config_path ='lp://MFD/faster_rcnn_R_50_FPN_3x/config', # In model catalog
4 label_map ={0: "Text", 1: "Title", 2: "List", 3:"Table", 4:"Figure"}, # In modellabel_map
5 extra_config=["MODEL.ROI_HEADS.SCORE_THRESH_TEST", 0.7] # Optional

16 frames

/usr/local/lib/python3.10/dist-packages/detectron2/data/transforms/transform.py in ExtentTransform()
44 """
45
---> 46 def init(self, src_rect, output_size, interp=Image.LINEAR, fill=0):
47 """
48 Args:

AttributeError: module 'PIL.Image' has no attribute 'LINEAR'

@Aman-Preet-Singh-Gulati Aman-Preet-Singh-Gulati added the bug Something isn't working label Jul 24, 2023
@risk-seeking
Copy link

I believe if you pip install Pillow==9.5.0, that can address the issue, although now I'm running into "AssertionError: Checkpoint .../model_final.pth not found!", so that's fun.

@Rabbitzzc
Copy link

refer: facebookresearch/detectron2#5010 (comment)
fixed by python3 -m pip install -U 'git+https://github.com/facebookresearch/detectron2.git@ff53992b1985b63bd3262b5a36167098e3dada02'

@yudataguy
Copy link

Install dectron2 0.6 and Pillow==9.50 fixed this issue.

@sdy623
Copy link

sdy623 commented Sep 27, 2023

In the Pillow's 10.0 version the PIL.Image.LINEAR is deprecated and will be removed in Pillow 10, you should change it with Resampling.BILINEAR

@snimavat
Copy link

snimavat commented Sep 4, 2024

python3 -m pip install -U 'git+https://github.com/facebookresearch/detectron2.git@ff53992b1985b63bd3262b5a36167098e3dada02'

This fixed it for me

But now i am getting another error

Checkpoint /Users/sudhir/.torch/iopath_cache/s/h7th27jfv19rxiy/model_final.pth not found!

@snimavat
Copy link

snimavat commented Sep 4, 2024

Downgrading pillow : pip install pillow==9.5.0 solved it for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants