Commit ·
cc84872
1
Parent(s): 8ec1624
limit dependencies
Browse files- app.py +4 -9
- requirements.txt +0 -0
app.py
CHANGED
|
@@ -2,9 +2,7 @@ import fitz # PyMuPDF
|
|
| 2 |
import gradio as gr
|
| 3 |
import zipfile
|
| 4 |
import io
|
| 5 |
-
import os
|
| 6 |
from datetime import datetime
|
| 7 |
-
import tempfile
|
| 8 |
|
| 9 |
# Helper function to find color areas
|
| 10 |
def find_color_areas(page, target_color, tolerance=30):
|
|
@@ -141,15 +139,12 @@ def process_pdf_files(input_pdfs, selected_color_comment_indices, tolerance, cus
|
|
| 141 |
# Move pointer to the beginning of the ZIP file BytesIO object
|
| 142 |
zip_in_memory.seek(0)
|
| 143 |
|
| 144 |
-
#
|
| 145 |
current_date = datetime.now().strftime("%Y-%m-%d")
|
| 146 |
-
|
| 147 |
-
# Create a named temporary file to store the ZIP
|
| 148 |
-
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=f"_CoordinationPDFS_{current_date}.zip")
|
| 149 |
-
with open(temp_file.name, 'wb') as tmp_file:
|
| 150 |
-
tmp_file.write(zip_in_memory.read())
|
| 151 |
|
| 152 |
-
|
|
|
|
| 153 |
|
| 154 |
# Define the Gradio interface
|
| 155 |
interface = gr.Interface(
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import zipfile
|
| 4 |
import io
|
|
|
|
| 5 |
from datetime import datetime
|
|
|
|
| 6 |
|
| 7 |
# Helper function to find color areas
|
| 8 |
def find_color_areas(page, target_color, tolerance=30):
|
|
|
|
| 139 |
# Move pointer to the beginning of the ZIP file BytesIO object
|
| 140 |
zip_in_memory.seek(0)
|
| 141 |
|
| 142 |
+
# Set the filename for the ZIP file
|
| 143 |
current_date = datetime.now().strftime("%Y-%m-%d")
|
| 144 |
+
zip_filename = f"CoordinationPDFS_{current_date}.zip"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
+
# Return the in-memory ZIP file and its filename for Gradio to download
|
| 147 |
+
return (zip_filename, zip_in_memory)
|
| 148 |
|
| 149 |
# Define the Gradio interface
|
| 150 |
interface = gr.Interface(
|
requirements.txt
CHANGED
|
Binary files a/requirements.txt and b/requirements.txt differ
|
|
|