Код: Выделить всё
Neither CUDA nor MPS are available - defaulting to CPU. Note: This module is much faster with a GPU.
Downloading detection model, please wait. This may take several minutes depending upon your network connection.
Вот реализация кода:
Код: Выделить всё
def process_ocr_pdf(pdf_file):
"""Main function to process PDF and extract text using OCR."""
try:
# Create reader once
reader = easyocr.Reader(['en'])
# Reset file pointer to beginning
pdf_file.seek(0)
# Extract images
images = extract_images_from_pdf(pdf_file)
if not images:
return None
# Extract text from each image
texts = []
for img in images:
text = extract_text_from_image(reader, img)
if text:
texts.append(text)
return texts if texts else None
except Exception as e:
print(f"Failed to process the file: {e}")
return None
Подробнее здесь: https://stackoverflow.com/questions/793 ... le-default