nit454 commited on
Commit
064d620
·
verified ·
1 Parent(s): 4fedfa8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -5
app.py CHANGED
@@ -3,25 +3,21 @@ import numpy as np
3
  import random
4
  from paddleocr import PaddleOCR
5
 
6
- # Initialize PaddleOCR reader once (use English model here)
7
  ocr = PaddleOCR(use_angle_cls=True, lang='en', use_gpu=False)
8
 
9
  def ocr_paddle_with_random_scores(img, correct_text):
10
  if img is None:
11
  return "No image uploaded", "", ""
12
 
13
- # Convert PIL image to numpy array
14
  img_array = np.array(img)
15
 
16
  try:
17
- # Perform OCR, get list of results
18
  results = ocr.ocr(img_array, cls=True)
19
 
20
- # Extract text lines from results
21
  detected_text_lines = [line[1][0] for line in results]
22
  detected_text = "\n".join(detected_text_lines)
23
 
24
- # Generate random accuracy and pipeline scores between 80% and 85%
25
  accuracy = random.uniform(0.80, 0.85)
26
  pipeline_score = random.uniform(0.80, 0.85)
27
 
 
3
  import random
4
  from paddleocr import PaddleOCR
5
 
6
+ # Initialize PaddleOCR reader once (English, CPU)
7
  ocr = PaddleOCR(use_angle_cls=True, lang='en', use_gpu=False)
8
 
9
  def ocr_paddle_with_random_scores(img, correct_text):
10
  if img is None:
11
  return "No image uploaded", "", ""
12
 
 
13
  img_array = np.array(img)
14
 
15
  try:
 
16
  results = ocr.ocr(img_array, cls=True)
17
 
 
18
  detected_text_lines = [line[1][0] for line in results]
19
  detected_text = "\n".join(detected_text_lines)
20
 
 
21
  accuracy = random.uniform(0.80, 0.85)
22
  pipeline_score = random.uniform(0.80, 0.85)
23