Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,6 @@ from langchain.chains import RetrievalQA
|
|
7 |
from langchain.prompts import PromptTemplate
|
8 |
from pdf2image import convert_from_path
|
9 |
import os
|
10 |
-
import io # Für in-memory Dateioperationen
|
11 |
|
12 |
class LayoutLMv3OCR:
|
13 |
def __init__(self):
|
@@ -44,8 +43,10 @@ def process_pdf_and_query(pdf_path, question):
|
|
44 |
def chatbot_response(pdf, question):
|
45 |
# Speichern der hochgeladenen PDF-Datei im Arbeitsspeicher
|
46 |
pdf_path = "uploaded_pdf.pdf"
|
|
|
|
|
47 |
with open(pdf_path, "wb") as f:
|
48 |
-
f.write(pdf.
|
49 |
|
50 |
# OCR-Textextraktion
|
51 |
extracted_text = ocr_tool.extract_text(pdf_path)
|
@@ -72,4 +73,4 @@ interface = gr.Interface(
|
|
72 |
)
|
73 |
|
74 |
if __name__ == "__main__":
|
75 |
-
interface.launch() # Kein öffentlicher Link, nur lokal
|
|
|
7 |
from langchain.prompts import PromptTemplate
|
8 |
from pdf2image import convert_from_path
|
9 |
import os
|
|
|
10 |
|
11 |
class LayoutLMv3OCR:
|
12 |
def __init__(self):
|
|
|
43 |
def chatbot_response(pdf, question):
|
44 |
# Speichern der hochgeladenen PDF-Datei im Arbeitsspeicher
|
45 |
pdf_path = "uploaded_pdf.pdf"
|
46 |
+
|
47 |
+
# Wir müssen den Inhalt des 'pdf' objekts direkt lesen, ohne auf 'file' zuzugreifen
|
48 |
with open(pdf_path, "wb") as f:
|
49 |
+
f.write(pdf.read()) # Hier wird der Inhalt der hochgeladenen Datei in eine PDF gespeichert
|
50 |
|
51 |
# OCR-Textextraktion
|
52 |
extracted_text = ocr_tool.extract_text(pdf_path)
|
|
|
73 |
)
|
74 |
|
75 |
if __name__ == "__main__":
|
76 |
+
interface.launch(share=False) # Kein öffentlicher Link, nur lokal
|