File size: 471 Bytes
79fc11d
 
 
 
 
d813a84
 
79fc11d
 
d813a84
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import layoutparser as lp
import pytesseract
from pdf2image import convert_from_path
from PIL import Image

def convert_pdf_to_images(pdf_path):
    return convert_from_path(pdf_path)

def analyze_layout(image):
    model = lp.EfficientDetLayoutModel(
        "lp://efficientdet/PubLayNet",
        extra_config=["MODEL.ROI_HEADS.SCORE_THRESH_TEST", 0.6],
        label_map={0: "Text", 1: "Title", 2: "List", 3: "Table", 4: "Figure"}
    )
    return model.detect(image)