mkaramb commited on
Commit
2a9e87f
·
verified ·
1 Parent(s): 58dc438

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
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
- return results_df.to_html()
177
 
178
- css = """
179
- body { font-family: Arial, sans-serif; }
180
- .input-container, .output-container {
181
- width: 95%;
182
- margin: 10px auto 20px; /* centers the containers and adds vertical spacing */
183
- display: block; /* ensures containers are treated as block elements */
184
- }
185
- """
186
 
187
  interface = gr.Interface(
188
  fn=process_images,
189
  inputs="file",
190
- outputs="html",
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__":