imperiusrex commited on
Commit
c160de9
Β·
verified Β·
1 Parent(s): ab94877

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -5
app.py CHANGED
@@ -6,13 +6,11 @@ import numpy as np
6
  import cv2
7
  from paddleocr import TextDetection
8
 
9
- # --- Constants ---
10
  MODEL_HUB_ID = "imperiusrex/Handwritten_model"
11
 
12
- # --- Device ---
13
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
14
 
15
- # --- Load Models Globally ---
16
  print("πŸ”„ Loading models...")
17
 
18
  processor = TrOCRProcessor.from_pretrained(MODEL_HUB_ID)
@@ -24,7 +22,6 @@ ocr_det_model = TextDetection(model_name="PP-OCRv5_server_det")
24
 
25
  print("βœ… Models loaded successfully.")
26
 
27
- # --- Inference Function ---
28
  def recognize_handwritten_text(image_input):
29
  if image_input is None:
30
  return "Please upload an image."
@@ -89,7 +86,6 @@ def build_interface():
89
  description="πŸ“· Upload a handwritten image. Uses PaddleOCR (detection) + TrOCR (recognition).",
90
  )
91
 
92
- # --- Launch App ---
93
  if __name__ == "__main__":
94
  iface = build_interface()
95
  iface.launch()
 
6
  import cv2
7
  from paddleocr import TextDetection
8
 
9
+
10
  MODEL_HUB_ID = "imperiusrex/Handwritten_model"
11
 
 
12
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
13
 
 
14
  print("πŸ”„ Loading models...")
15
 
16
  processor = TrOCRProcessor.from_pretrained(MODEL_HUB_ID)
 
22
 
23
  print("βœ… Models loaded successfully.")
24
 
 
25
  def recognize_handwritten_text(image_input):
26
  if image_input is None:
27
  return "Please upload an image."
 
86
  description="πŸ“· Upload a handwritten image. Uses PaddleOCR (detection) + TrOCR (recognition).",
87
  )
88
 
 
89
  if __name__ == "__main__":
90
  iface = build_interface()
91
  iface.launch()