heerjtdev commited on
Commit
80c0a3d
·
verified ·
1 Parent(s): d5df69a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -340,6 +340,7 @@ def run_single_pdf_preprocessing(pdf_path: str) -> Tuple[int, int, int, str, flo
340
  global GLOBAL_FIGURE_COUNT, GLOBAL_EQUATION_COUNT
341
  start_time = time.time()
342
  log_messages = []
 
343
  all_base64_images: List[str] = []
344
 
345
  # Dictionary to store {page_number (int): equation_count (int)}
@@ -399,7 +400,7 @@ def run_single_pdf_preprocessing(pdf_path: str) -> Tuple[int, int, int, str, flo
399
  detect_start = time.time()
400
  # page_equations, _ = run_yolo_detection_and_count(original_img, model, page_num)
401
  page_equations, _, page_images = run_yolo_detection_and_count(original_img, model, page_num)
402
- all_base64_images.extend(page_images)
403
 
404
  detect_time = time.time() - detect_start
405
 
@@ -437,7 +438,8 @@ def run_single_pdf_preprocessing(pdf_path: str) -> Tuple[int, int, int, str, flo
437
 
438
  # Return the dictionary with string keys
439
  # return total_pages, GLOBAL_EQUATION_COUNT, GLOBAL_FIGURE_COUNT, report, total_execution_time, equation_counts_per_page_str_keys, []
440
- return total_pages, GLOBAL_EQUATION_COUNT, GLOBAL_FIGURE_COUNT, report, total_execution_time, equation_counts_per_page_str_keys, all_base64_images
 
441
 
442
 
443
  # ============================================================================
@@ -459,8 +461,10 @@ def gradio_process_pdf(pdf_file) -> Tuple[str, str, str, str, Dict[str, int], Li
459
  # num_pages, num_equations, num_figures, report, total_time, equation_counts_per_page, _ = run_single_pdf_preprocessing(
460
  # pdf_path
461
  # )
 
462
  num_pages, num_equations, num_figures, report, total_time, equation_counts_per_page, images = run_single_pdf_preprocessing(pdf_path)
463
 
 
464
 
465
  # Return results (6 items now)
466
  # return str(num_pages), str(num_equations), str(num_figures), report, equation_counts_per_page, []
 
340
  global GLOBAL_FIGURE_COUNT, GLOBAL_EQUATION_COUNT
341
  start_time = time.time()
342
  log_messages = []
343
+ all_saved_images = []
344
  all_base64_images: List[str] = []
345
 
346
  # Dictionary to store {page_number (int): equation_count (int)}
 
400
  detect_start = time.time()
401
  # page_equations, _ = run_yolo_detection_and_count(original_img, model, page_num)
402
  page_equations, _, page_images = run_yolo_detection_and_count(original_img, model, page_num)
403
+ all_saved_images.extend(page_images)
404
 
405
  detect_time = time.time() - detect_start
406
 
 
438
 
439
  # Return the dictionary with string keys
440
  # return total_pages, GLOBAL_EQUATION_COUNT, GLOBAL_FIGURE_COUNT, report, total_execution_time, equation_counts_per_page_str_keys, []
441
+ return total_pages, GLOBAL_EQUATION_COUNT, GLOBAL_FIGURE_COUNT, report, total_execution_time, equation_counts_per_page_str_keys, all_saved_images
442
+
443
 
444
 
445
  # ============================================================================
 
461
  # num_pages, num_equations, num_figures, report, total_time, equation_counts_per_page, _ = run_single_pdf_preprocessing(
462
  # pdf_path
463
  # )
464
+ # num_pages, num_equations, num_figures, report, total_time, equation_counts_per_page, images = run_single_pdf_preprocessing(pdf_path)
465
  num_pages, num_equations, num_figures, report, total_time, equation_counts_per_page, images = run_single_pdf_preprocessing(pdf_path)
466
 
467
+
468
 
469
  # Return results (6 items now)
470
  # return str(num_pages), str(num_equations), str(num_figures), report, equation_counts_per_page, []