Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,22 +21,26 @@ import spaces
|
|
21 |
import pytesseract
|
22 |
from PIL import Image
|
23 |
|
24 |
-
|
|
|
25 |
|
26 |
-
|
27 |
-
print(
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
34 |
|
35 |
"""
|
36 |
Paddle OCR
|
37 |
"""
|
38 |
@spaces.GPU
|
39 |
def ocr_with_paddle(img):
|
|
|
40 |
finaltext = ''
|
41 |
ocr = PaddleOCR(use_gpu=True,lang='en',use_angle_cls=True)
|
42 |
# img_path = 'exp.jpeg'
|
@@ -53,6 +57,7 @@ Keras OCR
|
|
53 |
"""
|
54 |
@spaces.GPU
|
55 |
def ocr_with_keras(img):
|
|
|
56 |
output_text = ''
|
57 |
pipeline=keras_ocr.pipeline.Pipeline()
|
58 |
images=[keras_ocr.tools.read(img)]
|
|
|
21 |
import pytesseract
|
22 |
from PIL import Image
|
23 |
|
24 |
+
zero = torch.Tensor([0]).cuda()
|
25 |
+
tf.config.experimental.set_memory_growth(zero, True)
|
26 |
|
27 |
+
os.environ['CUDA_VISIBLE_DEVICES'] = zero
|
28 |
+
print(zero.device)
|
29 |
+
# gpus = tf.config.experimental.list_physical_devices('GPU')
|
30 |
+
# print("\n\n gpus :",gpus)
|
31 |
+
# if gpus:
|
32 |
+
# try:
|
33 |
+
# for gpu in gpus:
|
34 |
+
# tf.config.experimental.set_memory_growth(gpu, True)
|
35 |
+
# except RuntimeError as e:
|
36 |
+
# print(e)
|
37 |
|
38 |
"""
|
39 |
Paddle OCR
|
40 |
"""
|
41 |
@spaces.GPU
|
42 |
def ocr_with_paddle(img):
|
43 |
+
print(zero.device)
|
44 |
finaltext = ''
|
45 |
ocr = PaddleOCR(use_gpu=True,lang='en',use_angle_cls=True)
|
46 |
# img_path = 'exp.jpeg'
|
|
|
57 |
"""
|
58 |
@spaces.GPU
|
59 |
def ocr_with_keras(img):
|
60 |
+
print(zero.device)
|
61 |
output_text = ''
|
62 |
pipeline=keras_ocr.pipeline.Pipeline()
|
63 |
images=[keras_ocr.tools.read(img)]
|