OmidSakaki commited on
Commit
2d23095
·
verified ·
1 Parent(s): dd4c7df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -5,7 +5,7 @@ from PIL import Image
5
 
6
  try:
7
  from paddleocr import PaddleOCR
8
- paddle_ocr = PaddleOCR(lang='fa', use_textline_orientation=True)
9
  except ImportError:
10
  raise ImportError("لطفا ابتدا paddlepaddle و paddleocr را نصب کنید: pip install paddlepaddle paddleocr")
11
 
@@ -21,7 +21,7 @@ def run_paddleocr(image):
21
  image = np.array(image)
22
 
23
  try:
24
- result = paddle_ocr.ocr(image, cls=True)
25
  return ' '.join([line[1][0] for line in result[0]]) if result else ''
26
  except Exception as e:
27
  return f"خطا در PaddleOCR: {str(e)}"
@@ -40,7 +40,6 @@ def run_trocr(image):
40
 
41
  def compare_models(image):
42
  """Compare PaddleOCR and TrOCR models"""
43
- # Convert to RGB if needed
44
  if isinstance(image, np.ndarray):
45
  image = Image.fromarray(image)
46
  image = image.convert("RGB")
@@ -58,7 +57,6 @@ def compare_models(image):
58
  results['TrOCR'] = run_trocr(image)
59
  times['TrOCR'] = time.time() - start
60
 
61
- # Create comparison table
62
  comparison = f"""
63
  <table style="width:100%">
64
  <tr>
 
5
 
6
  try:
7
  from paddleocr import PaddleOCR
8
+ paddle_ocr = PaddleOCR(lang='fa') # حذف پارامتر cls
9
  except ImportError:
10
  raise ImportError("لطفا ابتدا paddlepaddle و paddleocr را نصب کنید: pip install paddlepaddle paddleocr")
11
 
 
21
  image = np.array(image)
22
 
23
  try:
24
+ result = paddle_ocr.ocr(image) # حذف پارامتر cls
25
  return ' '.join([line[1][0] for line in result[0]]) if result else ''
26
  except Exception as e:
27
  return f"خطا در PaddleOCR: {str(e)}"
 
40
 
41
  def compare_models(image):
42
  """Compare PaddleOCR and TrOCR models"""
 
43
  if isinstance(image, np.ndarray):
44
  image = Image.fromarray(image)
45
  image = image.convert("RGB")
 
57
  results['TrOCR'] = run_trocr(image)
58
  times['TrOCR'] = time.time() - start
59
 
 
60
  comparison = f"""
61
  <table style="width:100%">
62
  <tr>