artificialguybr commited on
Commit
8ef414c
·
verified ·
1 Parent(s): 77deb1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -18,10 +18,20 @@ with open("languages.json", "r") as file:
18
  language_options = [(code, language) for code, language in languages.items()]
19
 
20
  def ocr_function(img, langs):
21
- predictions = run_ocr([img], langs.split(','), det_model, det_processor, rec_model, rec_processor)[0]
 
 
 
 
 
 
 
 
 
22
  img_with_text = draw_polys_on_image(predictions["polys"], img)
23
  return img_with_text, predictions
24
 
 
25
  def text_line_detection_function(img):
26
  preds = batch_detection([img], det_model, det_processor)[0]
27
  img_with_lines = draw_polys_on_image(preds["polygons"], img)
 
18
  language_options = [(code, language) for code, language in languages.items()]
19
 
20
  def ocr_function(img, langs):
21
+ # Debugging: Print the languages input
22
+ print("Languages input:", langs)
23
+ lang_list = langs.split(',')
24
+ print("Language list:", lang_list)
25
+
26
+ # Ensure we're passing a list of images and a list of languages with matching lengths
27
+ images = [img] # Wrap the single image in a list
28
+ assert len(images) == len(lang_list), "Mismatch in the number of images and languages"
29
+
30
+ predictions = run_ocr(images, lang_list, det_model, det_processor, rec_model, rec_processor)[0]
31
  img_with_text = draw_polys_on_image(predictions["polys"], img)
32
  return img_with_text, predictions
33
 
34
+
35
  def text_line_detection_function(img):
36
  preds = batch_detection([img], det_model, det_processor)[0]
37
  img_with_lines = draw_polys_on_image(preds["polygons"], img)