Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with open(filepath, 'rb') as file:
- pdf_stream = io.BytesIO(file.read())
- images = convert_from_bytes(pdf_stream.read())
- paths = []
- # Save images
- for i, image in enumerate(images):
- image.save(f'page{i}.png', 'PNG')
- paths.append(f'page{i}.png')
- # Load the document segmentation model
- # docseg_model_name = 'DILHTWD/documentlayoutsegmentation_YOLOv8_ondoclaynet'
- docseg_model = YOLO("yolov8x-doclaynet-epoch64-imgsz640-initiallr1e-4-finallr1e-5.pt")
- # Process the images with the model
- results = docseg_model(source=paths, save=True, show_labels=True, show_conf=True, show_boxes=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement