Update app.py
Browse files
app.py
CHANGED
@@ -173,24 +173,22 @@ def process_images(uploaded_file):
|
|
173 |
except Exception as e:
|
174 |
return f"An error occurred: {str(e)}"
|
175 |
|
176 |
-
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
.
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
"""
|
186 |
|
187 |
interface = gr.Interface(
|
188 |
fn=process_images,
|
189 |
inputs="file",
|
190 |
-
outputs="
|
191 |
title="Document AI Translation",
|
192 |
description="Upload a ZIP file containing JPEG/JPG images, and the system will extract and translate text from each image.",
|
193 |
-
css=css
|
194 |
)
|
195 |
|
196 |
if __name__ == "__main__":
|
|
|
173 |
except Exception as e:
|
174 |
return f"An error occurred: {str(e)}"
|
175 |
|
176 |
+
html_output = results_df.to_html()
|
177 |
|
178 |
+
# Save DataFrame to a temporary CSV file for download
|
179 |
+
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".csv") # Create a temp file
|
180 |
+
results_df.to_csv(temp_file.name, index=False) # Save DataFrame to CSV
|
181 |
+
temp_file.close() # Close the file
|
182 |
+
|
183 |
+
# Return HTML and the path to the CSV file
|
184 |
+
return html_output, temp_file.name
|
|
|
185 |
|
186 |
interface = gr.Interface(
|
187 |
fn=process_images,
|
188 |
inputs="file",
|
189 |
+
outputs=["HTML", "file"],
|
190 |
title="Document AI Translation",
|
191 |
description="Upload a ZIP file containing JPEG/JPG images, and the system will extract and translate text from each image.",
|
|
|
192 |
)
|
193 |
|
194 |
if __name__ == "__main__":
|