anikde commited on
Commit
4aa9ef2
·
1 Parent(s): da8e486

added GPU config

Browse files
IndicPhotoOCR/ocr.py CHANGED
@@ -121,7 +121,7 @@ class OCR:
121
  """Recognize text in a cropped image area using the identified script."""
122
  if self.verbose:
123
  print("Recognizing text in detected area...")
124
- recognized_text = self.recogniser.recognise(script_lang, cropped_image_path, script_lang, self.verbose)
125
  # print(recognized_text)
126
  return recognized_text
127
 
 
121
  """Recognize text in a cropped image area using the identified script."""
122
  if self.verbose:
123
  print("Recognizing text in detected area...")
124
+ recognized_text = self.recogniser.recognise(script_lang, cropped_image_path, script_lang, self.verbose, self.device)
125
  # print(recognized_text)
126
  return recognized_text
127
 
IndicPhotoOCR/recognition/parseq_recogniser.py CHANGED
@@ -188,7 +188,7 @@ class PARseqrecogniser:
188
  return text
189
 
190
 
191
- def recognise(self, checkpoint: str, image_path: str, language: str, verbose: bool) -> str:
192
  """
193
  Loads the desired model and returns the recognized word from the specified image.
194
 
@@ -200,7 +200,7 @@ class PARseqrecogniser:
200
  Returns:
201
  str: The recognized text from the image.
202
  """
203
- device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
204
 
205
  if language != "english":
206
  model_path = self.ensure_model(checkpoint)
 
188
  return text
189
 
190
 
191
+ def recognise(self, checkpoint: str, image_path: str, language: str, verbose: bool, device: str) -> str:
192
  """
193
  Loads the desired model and returns the recognized word from the specified image.
194
 
 
200
  Returns:
201
  str: The recognized text from the image.
202
  """
203
+ # device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
204
 
205
  if language != "english":
206
  model_path = self.ensure_model(checkpoint)
app.py CHANGED
@@ -6,7 +6,7 @@ from IndicPhotoOCR.theme import Seafoam
6
  from IndicPhotoOCR.utils.helper import detect_para
7
 
8
  # Initialize the OCR object for text detection and recognition
9
- ocr = OCR(device="cpu", verbose=False)
10
 
11
  def process_image(image):
12
  """
@@ -129,7 +129,7 @@ demo = gr.Interface(
129
  # # Server setup and launch configuration
130
  # if __name__ == "__main__":
131
  # server = "0.0.0.0" # IP address for server
132
- # port = 7865 # Port to run the server on
133
  # demo.launch(server_name=server, server_port=port, share=True)
134
 
135
  demo.launch()
 
6
  from IndicPhotoOCR.utils.helper import detect_para
7
 
8
  # Initialize the OCR object for text detection and recognition
9
+ ocr = OCR(verbose=False)
10
 
11
  def process_image(image):
12
  """
 
129
  # # Server setup and launch configuration
130
  # if __name__ == "__main__":
131
  # server = "0.0.0.0" # IP address for server
132
+ # port = 7866 # Port to run the server on
133
  # demo.launch(server_name=server, server_port=port, share=True)
134
 
135
  demo.launch()