ApsidalSolid4 commited on
Commit
69b98d8
·
verified ·
1 Parent(s): 67d8613

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -11
app.py CHANGED
@@ -33,36 +33,29 @@ MODEL_NAME = "microsoft/deberta-v3-small"
33
  WINDOW_SIZE = 6
34
  WINDOW_OVERLAP = 2
35
  CONFIDENCE_THRESHOLD = 0.65
36
- BATCH_SIZE = 8 # Reduced batch size for CPU
37
- MAX_WORKERS = 4 # Number of worker threads for processing
 
38
 
39
- # IMPORTANT: Set PyTorch thread configuration at the module level
40
- # before any parallel work starts
41
  if not torch.cuda.is_available():
42
- # Set thread configuration only once at the beginning
43
  torch.set_num_threads(MAX_WORKERS)
44
  try:
45
- # Only set interop threads if it hasn't been set already
46
  torch.set_num_interop_threads(MAX_WORKERS)
47
  except RuntimeError as e:
48
  logger.warning(f"Could not set interop threads: {str(e)}")
49
 
50
- # Get password hash from environment variable (more secure)
51
  ADMIN_PASSWORD_HASH = os.environ.get('ADMIN_PASSWORD_HASH')
52
 
53
  if not ADMIN_PASSWORD_HASH:
54
  ADMIN_PASSWORD_HASH = "5e22d1ed71b273b1b2b5331f2d3e0f6cf34595236f201c6924d6bc81de27cdcb"
55
 
56
- # Excel file path for logs
57
  EXCEL_LOG_PATH = "/tmp/prediction_logs.xlsx"
58
 
59
- # OCR API settings
60
- OCR_API_KEY = "9e11346f1288957" # Now using the complete key
61
  OCR_API_ENDPOINT = "https://api.ocr.space/parse/image"
62
  OCR_MAX_PDF_PAGES = 3
63
  OCR_MAX_FILE_SIZE_MB = 1
64
 
65
- # Configure logging for OCR module
66
  ocr_logger = logging.getLogger("ocr_module")
67
  ocr_logger.setLevel(logging.INFO)
68
 
 
33
  WINDOW_SIZE = 6
34
  WINDOW_OVERLAP = 2
35
  CONFIDENCE_THRESHOLD = 0.65
36
+ BATCH_SIZE = 8
37
+ MAX_WORKERS = 4
38
+
39
 
 
 
40
  if not torch.cuda.is_available():
 
41
  torch.set_num_threads(MAX_WORKERS)
42
  try:
 
43
  torch.set_num_interop_threads(MAX_WORKERS)
44
  except RuntimeError as e:
45
  logger.warning(f"Could not set interop threads: {str(e)}")
46
 
 
47
  ADMIN_PASSWORD_HASH = os.environ.get('ADMIN_PASSWORD_HASH')
48
 
49
  if not ADMIN_PASSWORD_HASH:
50
  ADMIN_PASSWORD_HASH = "5e22d1ed71b273b1b2b5331f2d3e0f6cf34595236f201c6924d6bc81de27cdcb"
51
 
 
52
  EXCEL_LOG_PATH = "/tmp/prediction_logs.xlsx"
53
 
54
+ OCR_API_KEY = "9e11346f1288957"
 
55
  OCR_API_ENDPOINT = "https://api.ocr.space/parse/image"
56
  OCR_MAX_PDF_PAGES = 3
57
  OCR_MAX_FILE_SIZE_MB = 1
58
 
 
59
  ocr_logger = logging.getLogger("ocr_module")
60
  ocr_logger.setLevel(logging.INFO)
61