Genzo1010 commited on
Commit
dbf7058
·
verified ·
1 Parent(s): c525e08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -12,10 +12,22 @@ os.environ['USE_TF'] = '0' # Set TensorFlow to off
12
  os.environ['USE_TORCH'] = '1' # Set PyTorch to on
13
 
14
  from doctr.models import ocr_predictor
15
- ocr_model = ocr_predictor(det_arch='db_resnet50', reco_arch='crnn_vgg16_bn', pretrained=True)
16
 
 
17
 
 
18
 
 
 
 
 
 
 
 
 
 
 
19
  """
20
  Perform OCR with doctr
21
  """
 
12
  os.environ['USE_TORCH'] = '1' # Set PyTorch to on
13
 
14
  from doctr.models import ocr_predictor
15
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
16
 
17
+ # Example for PyTorch model or doctr model
18
 
19
+ ocr_model = ocr_predictor(det_arch='db_resnet50', reco_arch='crnn_vgg16_bn', pretrained=True).to(device)
20
 
21
+
22
+ import torch
23
+
24
+ # Check if CUDA is available
25
+ if torch.cuda.is_available():
26
+ print(f"GPU is available. Device: {torch.cuda.get_device_name(0)}")
27
+ else:
28
+ print("GPU is not available, using CPU.")
29
+
30
+
31
  """
32
  Perform OCR with doctr
33
  """