pragnakalp commited on
Commit
e55ec6f
·
verified ·
1 Parent(s): 54fa052

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -17,15 +17,15 @@ from datasets import load_dataset, Image
17
  from PIL import Image
18
  from paddleocr import PaddleOCR
19
  from save_data import flag
20
- # import spaces
21
  import pytesseract
22
  from PIL import Image
23
- # import torch
24
 
25
  """
26
  Paddle OCR
27
  """
28
- # @spaces.GPU
29
  def ocr_with_paddle(img):
30
  finaltext = ''
31
  ocr = PaddleOCR(use_gpu=True,lang='en',use_angle_cls=True)
@@ -41,10 +41,10 @@ def ocr_with_paddle(img):
41
  """
42
  Keras OCR
43
  """
44
- # @spaces.GPU
45
  def ocr_with_keras(img):
46
  output_text = ''
47
- pipeline=keras_ocr.pipeline.Pipeline()
48
  images=[keras_ocr.tools.read(img)]
49
  predictions=pipeline.recognize(images)
50
  first=predictions[0]
@@ -63,7 +63,7 @@ def get_grayscale(image):
63
  def thresholding(src):
64
  return cv2.threshold(src,127,255, cv2.THRESH_TOZERO)[1]
65
 
66
- # @spaces.GPU
67
  def ocr_with_easy(img):
68
  gray_scale_image=get_grayscale(img)
69
  thresholding(gray_scale_image)
@@ -76,12 +76,9 @@ def ocr_with_easy(img):
76
  """
77
  Generate OCR
78
  """
79
- # @spaces.GPU
80
  def generate_ocr(Method,img):
81
 
82
  text_output = ''
83
- print("\n\n img :",img.any())
84
- print("\n\n img.any :",(img).any())
85
  if img.any() or (img).any():
86
  add_csv = []
87
  image_id = 1
 
17
  from PIL import Image
18
  from paddleocr import PaddleOCR
19
  from save_data import flag
20
+ import spaces
21
  import pytesseract
22
  from PIL import Image
23
+ import torch
24
 
25
  """
26
  Paddle OCR
27
  """
28
+ @spaces.GPU
29
  def ocr_with_paddle(img):
30
  finaltext = ''
31
  ocr = PaddleOCR(use_gpu=True,lang='en',use_angle_cls=True)
 
41
  """
42
  Keras OCR
43
  """
44
+ @spaces.GPU
45
  def ocr_with_keras(img):
46
  output_text = ''
47
+ pipeline=keras_ocr.pipeline.Pipeline().to_device()
48
  images=[keras_ocr.tools.read(img)]
49
  predictions=pipeline.recognize(images)
50
  first=predictions[0]
 
63
  def thresholding(src):
64
  return cv2.threshold(src,127,255, cv2.THRESH_TOZERO)[1]
65
 
66
+ @spaces.GPU
67
  def ocr_with_easy(img):
68
  gray_scale_image=get_grayscale(img)
69
  thresholding(gray_scale_image)
 
76
  """
77
  Generate OCR
78
  """
 
79
  def generate_ocr(Method,img):
80
 
81
  text_output = ''
 
 
82
  if img.any() or (img).any():
83
  add_csv = []
84
  image_id = 1