pragnakalp commited on
Commit
a33c6a8
1 Parent(s): 3b1933d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -16
app.py CHANGED
@@ -21,23 +21,11 @@ import spaces
21
  import pytesseract
22
  from PIL import Image
23
  import torch
24
-
25
- zero = torch.Tensor([0]).cuda()
26
-
27
- print(zero.device)
28
- # gpus = tf.config.experimental.list_physical_devices('GPU')
29
- # print("\n\n gpus :",gpus)
30
- # if gpus:
31
- # try:
32
- # for gpu in gpus:
33
- # tf.config.experimental.set_memory_growth(gpu, True)
34
- # except RuntimeError as e:
35
- # print(e)
36
-
37
  """
38
  Paddle OCR
39
  """
40
- @spaces.GPU
41
  def ocr_with_paddle(img):
42
  print(zero.device)
43
  finaltext = ''
@@ -54,7 +42,7 @@ def ocr_with_paddle(img):
54
  """
55
  Keras OCR
56
  """
57
- @spaces.GPU
58
  def ocr_with_keras(img):
59
  print(zero.device)
60
  output_text = ''
@@ -77,7 +65,7 @@ def get_grayscale(image):
77
  def thresholding(src):
78
  return cv2.threshold(src,127,255, cv2.THRESH_TOZERO)[1]
79
 
80
- @spaces.GPU
81
  def ocr_with_easy(img):
82
  gray_scale_image=get_grayscale(img)
83
  thresholding(gray_scale_image)
@@ -90,6 +78,7 @@ def ocr_with_easy(img):
90
  """
91
  Generate OCR
92
  """
 
93
  def generate_ocr(Method,img):
94
 
95
  text_output = ''
 
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
  print(zero.device)
31
  finaltext = ''
 
42
  """
43
  Keras OCR
44
  """
45
+ # @spaces.GPU
46
  def ocr_with_keras(img):
47
  print(zero.device)
48
  output_text = ''
 
65
  def thresholding(src):
66
  return cv2.threshold(src,127,255, cv2.THRESH_TOZERO)[1]
67
 
68
+ # @spaces.GPU
69
  def ocr_with_easy(img):
70
  gray_scale_image=get_grayscale(img)
71
  thresholding(gray_scale_image)
 
78
  """
79
  Generate OCR
80
  """
81
+ @spaces.GPU
82
  def generate_ocr(Method,img):
83
 
84
  text_output = ''