Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
from fastapi.responses import RedirectResponse
|
3 |
-
import fitz
|
4 |
import docx
|
5 |
import openpyxl
|
6 |
import pptx
|
@@ -25,7 +25,6 @@ def extract_text_from_pdf(file_bytes):
|
|
25 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp:
|
26 |
tmp.write(file_bytes)
|
27 |
tmp_path = tmp.name
|
28 |
-
|
29 |
with fitz.open(tmp_path) as doc:
|
30 |
text = "\n".join(page.get_text() for page in doc)
|
31 |
os.unlink(tmp_path)
|
@@ -116,7 +115,7 @@ img_caption = gr.Interface(
|
|
116 |
)
|
117 |
|
118 |
# -------------------------
|
119 |
-
#
|
120 |
# -------------------------
|
121 |
demo = gr.TabbedInterface([doc_summary, img_caption], ["Document Summary", "Image Captioning"])
|
122 |
app = gr.mount_gradio_app(app, demo, path="/")
|
|
|
1 |
from fastapi import FastAPI
|
2 |
from fastapi.responses import RedirectResponse
|
3 |
+
import fitz
|
4 |
import docx
|
5 |
import openpyxl
|
6 |
import pptx
|
|
|
25 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp:
|
26 |
tmp.write(file_bytes)
|
27 |
tmp_path = tmp.name
|
|
|
28 |
with fitz.open(tmp_path) as doc:
|
29 |
text = "\n".join(page.get_text() for page in doc)
|
30 |
os.unlink(tmp_path)
|
|
|
115 |
)
|
116 |
|
117 |
# -------------------------
|
118 |
+
# FastAPI Integration
|
119 |
# -------------------------
|
120 |
demo = gr.TabbedInterface([doc_summary, img_caption], ["Document Summary", "Image Captioning"])
|
121 |
app = gr.mount_gradio_app(app, demo, path="/")
|