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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -40,7 +40,9 @@ logging.basicConfig(level=logging.WARNING)
40
 
41
  WEIGHTS_PATH = 'best.pt'
42
  SCALE_FACTOR = 2.0
43
- OUTPUT_DIR = "yolo_extracted_regions"
 
 
44
 
45
  # Detection parameters
46
  CONF_THRESHOLD = 0.2
@@ -350,6 +352,13 @@ def run_single_pdf_preprocessing(pdf_path: str) -> Tuple[int, int, int, str, flo
350
  GLOBAL_FIGURE_COUNT = 0
351
  GLOBAL_EQUATION_COUNT = 0
352
 
 
 
 
 
 
 
 
353
  # 1. Validation and Model Loading
354
  t0 = time.time()
355
  if not os.path.exists(pdf_path):
@@ -527,6 +536,10 @@ if __name__ == "__main__":
527
  )
528
 
529
  print("\nStarting Gradio application...")
530
- interface.launch(inbrowser=True)
 
 
 
 
531
 
532
 
 
40
 
41
  WEIGHTS_PATH = 'best.pt'
42
  SCALE_FACTOR = 2.0
43
+ # OUTPUT_DIR = "yolo_extracted_regions"
44
+ OUTPUT_DIR = os.path.join(tempfile.gettempdir(), "yolo_extracted_regions")
45
+
46
 
47
  # Detection parameters
48
  CONF_THRESHOLD = 0.2
 
352
  GLOBAL_FIGURE_COUNT = 0
353
  GLOBAL_EQUATION_COUNT = 0
354
 
355
+
356
+
357
+ if os.path.exists(OUTPUT_DIR):
358
+ shutil.rmtree(OUTPUT_DIR)
359
+ os.makedirs(OUTPUT_DIR, exist_ok=True)
360
+
361
+
362
  # 1. Validation and Model Loading
363
  t0 = time.time()
364
  if not os.path.exists(pdf_path):
 
536
  )
537
 
538
  print("\nStarting Gradio application...")
539
+ # interface.launch(inbrowser=True)
540
+ interface.launch(
541
+ inbrowser=True,
542
+ allowed_paths=[OUTPUT_DIR]
543
+ )
544
 
545