Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 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 =
|
| 39 |
|
| 40 |
def get_text(self, pdf_path: str) -> str:
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
return
|
| 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:
|