Spaces:
Build error
Build error
changing to Gradio
Browse files- app.py +15 -6
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import
|
| 2 |
from haystack.document_stores import InMemoryDocumentStore
|
| 3 |
from haystack.nodes import FARMReader, PreProcessor, PDFToTextConverter, TfidfRetriever
|
| 4 |
import logging
|
|
@@ -14,8 +14,6 @@ preprocessor = PreProcessor(
|
|
| 14 |
split_overlap=3
|
| 15 |
)
|
| 16 |
|
| 17 |
-
uploaded_files = st.file_uploader(label='Upload a PDF Document', accept_multiple_files=True)
|
| 18 |
-
logging.info(uploaded_files)
|
| 19 |
|
| 20 |
def pdf_to_document_store(pdf_files):
|
| 21 |
document_store.delete_documents()
|
|
@@ -27,6 +25,17 @@ def pdf_to_document_store(pdf_files):
|
|
| 27 |
document_store.write_documents(preprocessed_docs)
|
| 28 |
return None
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
from haystack.document_stores import InMemoryDocumentStore
|
| 3 |
from haystack.nodes import FARMReader, PreProcessor, PDFToTextConverter, TfidfRetriever
|
| 4 |
import logging
|
|
|
|
| 14 |
split_overlap=3
|
| 15 |
)
|
| 16 |
|
|
|
|
|
|
|
| 17 |
|
| 18 |
def pdf_to_document_store(pdf_files):
|
| 19 |
document_store.delete_documents()
|
|
|
|
| 25 |
document_store.write_documents(preprocessed_docs)
|
| 26 |
return None
|
| 27 |
|
| 28 |
+
|
| 29 |
+
def summarize(files):
|
| 30 |
+
if files is not None:
|
| 31 |
+
document_store.delete_all_documents()
|
| 32 |
+
pdf_to_document_store(files)
|
| 33 |
+
return document_store.get_document_count()
|
| 34 |
+
|
| 35 |
+
title = "Summarize one or more PDFs with a Haystack Summariser pipeline"
|
| 36 |
+
iface = gr.Interface(fn=summarize,
|
| 37 |
+
inputs=[gr.inputs.File(file_count="multiple", type="file", label="Upload some PDFs")],
|
| 38 |
+
outputs="text",
|
| 39 |
+
title=title,
|
| 40 |
+
theme="huggingface")
|
| 41 |
+
iface.launch()
|
requirements.txt
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
farm-haystack==1.4.0
|
|
|
|
| 1 |
+
farm-haystack[ocr]==1.4.0
|