0

following is my Dockerfile.

FROM python:3.9
RUN apt-get clean && apt-get update
pip install --upgrade pip

RUN pip install layoutparser 

RUN pip install "layoutparser[ocr]" 

RUN pip install pytesseract 

RUN pip install pdf2image 

RUN pip install torch 

RUN pip install torchvision

RUN apt-get install -y poppler-utils  #(pdf-image) 

RUN apt-get install -y tesseract-ocr 

RUN apt-get install git #(to install detectron2) 

RUN pip install "git+https://github.com/facebookresearch/detectron2.git"  #(detectron2 model) 

RUN apt-get update && apt-get install ffmpeg libsm6 libxext6  -y #(required to run packages)

workdir /home/jovyan/work/layout_parser

volume ["/home/jovyan/work/layout_parser"]

CMD ["python", "test_code.py"]

python code test_code.py:

import pdf2image
import layoutparser as lp
import pytesseract
import numpy as np
import cv2
import matplotlib.pyplot as plt


pdf_file= r"/home/jovyan/work/layout_parser/test_pdf.pdf"
image = np.asarray(pdf2image.convert_from_path(pdf_file)[0])

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


I received the following error: enter image description here

I have tried the following to resolve the issue without any success:

  • variations of torch and torchvision versions used
  • python 3.7, 3.8, 3.9 base used
  • variations of pre-built model's config_path used
  • Manually downloaded model as present in the config file -> layout_parser_modelzoo
  • tried manually downloaded model in extension pth and pkl. Received the following error: enter image description here

How could I use the pre-trained models?

SMI
  • 71
  • 1
  • 11
  • Was facing the same issue. This helped me fix: https://github.com/Layout-Parser/layout-parser/issues/15#:~:text=Aug%204%2C%202022-,One%20workaround%20I%20found%20is%2C%20to%20change%20the%20WEIGHTS%20path%20inside%20the%20config.yaml%20file.,-If%20the%20path – Lakshmi Narayanan Jul 18 '23 at 07:13

0 Answers0