pragnakalp commited on
Commit
7c0316e
1 Parent(s): 07e246b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -21,13 +21,15 @@ import spaces
21
  import pytesseract
22
  from PIL import Image
23
 
24
- # gpus = tf.config.experimental.list_physical_devices('GPU')
25
- # if gpus:
26
- # try:
27
- # for gpu in gpus:
28
- # tf.config.experimental.set_memory_growth(gpu, True)
29
- # except RuntimeError as e:
30
- # print(e)
 
 
31
 
32
  """
33
  Paddle OCR
@@ -48,6 +50,7 @@ def ocr_with_paddle(img):
48
  """
49
  Keras OCR
50
  """
 
51
  def ocr_with_keras(img):
52
  output_text = ''
53
  pipeline=keras_ocr.pipeline.Pipeline()
 
21
  import pytesseract
22
  from PIL import Image
23
 
24
+ os.environ['CUDA_VISIBLE_DEVICES'] = "0"
25
+
26
+ gpus = tf.config.experimental.list_physical_devices('GPU')
27
+ if gpus:
28
+ try:
29
+ for gpu in gpus:
30
+ tf.config.experimental.set_memory_growth(gpu, True)
31
+ except RuntimeError as e:
32
+ print(e)
33
 
34
  """
35
  Paddle OCR
 
50
  """
51
  Keras OCR
52
  """
53
+ @spaces.GPU
54
  def ocr_with_keras(img):
55
  output_text = ''
56
  pipeline=keras_ocr.pipeline.Pipeline()