Aumkeshchy2003 commited on
Commit
fe614e6
·
verified ·
1 Parent(s): 01e1d32

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -19,7 +19,7 @@ def search_and_highlight(text, keyword):
19
  highlighted_text = re.sub(f"({keyword})", r"<mark>\1</mark>", text, flags=re.IGNORECASE)
20
  return highlighted_text
21
 
22
- def ocr_and_search(image, keyword):
23
  if image is None:
24
  return "Please upload an image."
25
 
@@ -35,12 +35,12 @@ iface = gr.Interface(
35
  fn=ocr_and_search,
36
  inputs=[
37
  gr.Image(type="pil", label="Upload Image"),
38
- gr.Textbox(label="Enter keyword to search (optional)")
 
39
  ],
40
  outputs=gr.HTML(label="Extracted and Highlighted Text"),
41
  title="OCR and Keyword Search",
42
  description="Upload an image to extract text using OCR and optionally search for keywords in the extracted text."
43
  )
44
 
45
- if __name__ == '__main__':
46
- iface.launch()
 
19
  highlighted_text = re.sub(f"({keyword})", r"<mark>\1</mark>", text, flags=re.IGNORECASE)
20
  return highlighted_text
21
 
22
+ def ocr_and_search(image, keyword, languages):
23
  if image is None:
24
  return "Please upload an image."
25
 
 
35
  fn=ocr_and_search,
36
  inputs=[
37
  gr.Image(type="pil", label="Upload Image"),
38
+ gr.Textbox(label="Enter keyword to search (optional)"),
39
+ gr.CheckboxGroup(choices=language_choices, label="Select languages", default=["eng"])
40
  ],
41
  outputs=gr.HTML(label="Extracted and Highlighted Text"),
42
  title="OCR and Keyword Search",
43
  description="Upload an image to extract text using OCR and optionally search for keywords in the extracted text."
44
  )
45
 
46
+ iface.launch()