yashbyname commited on
Commit
53f01c5
·
verified ·
1 Parent(s): 945b7f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -36,7 +36,12 @@ def perform_ocr(img, language):
36
  if language in ["English", "Both"]:
37
  # Ensure that inference is done on the correct device (GPU or CPU)
38
  with torch.no_grad():
39
- res_eng = model_eng.chat(tokenizer_eng, img_path, ocr_type='ocr')
 
 
 
 
 
40
 
41
  if language in ["Hindi", "Both"]:
42
  img_cv = cv2.imread(img_path)
 
36
  if language in ["English", "Both"]:
37
  # Ensure that inference is done on the correct device (GPU or CPU)
38
  with torch.no_grad():
39
+ # Move inputs to the appropriate device
40
+ try:
41
+ res_eng = model_eng.chat(tokenizer_eng, img_path, ocr_type='ocr')
42
+ except Exception as e:
43
+ print(f"Error during English OCR: {e}")
44
+ res_eng = "Error during English OCR"
45
 
46
  if language in ["Hindi", "Both"]:
47
  img_cv = cv2.imread(img_path)