Advertisement
kopyl

Untitled

Mar 26th, 2024
728
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. with open(filepath, 'rb') as file:
  2.   pdf_stream = io.BytesIO(file.read())
  3. images = convert_from_bytes(pdf_stream.read())
  4. paths = []
  5. # Save images
  6. for i, image in enumerate(images):
  7.   image.save(f'page{i}.png', 'PNG')
  8.   paths.append(f'page{i}.png')
  9.  
  10.  
  11. # Load the document segmentation model
  12. # docseg_model_name = 'DILHTWD/documentlayoutsegmentation_YOLOv8_ondoclaynet'
  13. docseg_model = YOLO("yolov8x-doclaynet-epoch64-imgsz640-initiallr1e-4-finallr1e-5.pt")
  14.  
  15. # Process the images with the model
  16. 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