AyoubChLin commited on
Commit
1a272cd
·
verified ·
1 Parent(s): dfcd571

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -4,9 +4,7 @@ from fastapi.middleware.cors import CORSMiddleware
4
  import shutil
5
  import os
6
  from uuid import uuid4
7
- from marker.converters.pdf import PdfConverter
8
- from marker.models import create_model_dict
9
- from marker.output import text_from_rendered
10
  from threading import Lock
11
 
12
  app = FastAPI()
@@ -35,12 +33,12 @@ class PdfConverterSingleton:
35
  return cls._instance
36
 
37
  def _initialize(self):
38
- self.converter = PdfConverter(artifact_dict=create_model_dict())
39
 
40
  def get_text(self, pdf_path: str) -> str:
41
- rendered = self.converter(pdf_path)
42
- text, _, _ = text_from_rendered(rendered)
43
- return str(text)
44
 
45
  # API function to call converter
46
  def extract_text_from_pdf(pdf_path: str) -> str:
 
4
  import shutil
5
  import os
6
  from uuid import uuid4
7
+ from docling.document_converter import DocumentConverter
 
 
8
  from threading import Lock
9
 
10
  app = FastAPI()
 
33
  return cls._instance
34
 
35
  def _initialize(self):
36
+ self.converter = DocumentConverter()
37
 
38
  def get_text(self, pdf_path: str) -> str:
39
+ result = self.converter.convert(pdf_path)
40
+
41
+ return result.document.export_to_markdown()
42
 
43
  # API function to call converter
44
  def extract_text_from_pdf(pdf_path: str) -> str: